mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-29 08:33:37 +00:00
chore: fmt, remove subprojects
This commit is contained in:
parent
ab0ad12521
commit
1928c8b662
|
|
@ -46,19 +46,21 @@ void ConsoleUIController::init(S32 w, S32 h) {
|
|||
// init
|
||||
gdraw_funcs = gdraw_GL_CreateContext(w, h, 0);
|
||||
|
||||
if (!gdraw_funcs)
|
||||
{
|
||||
app.DebugPrintf("Failed to initialise GDraw GL!\n");
|
||||
app.FatalLoadError();
|
||||
}
|
||||
if (!gdraw_funcs) {
|
||||
app.DebugPrintf("Failed to initialise GDraw GL!\n");
|
||||
app.FatalLoadError();
|
||||
}
|
||||
|
||||
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_vertexbuffer, 5000, 16 * 1024 * 1024);
|
||||
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_texture, 5000, 128 * 1024 * 1024);
|
||||
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_rendertarget, 10, 32 * 1024 * 1024);
|
||||
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_vertexbuffer, 5000,
|
||||
16 * 1024 * 1024);
|
||||
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_texture, 5000,
|
||||
128 * 1024 * 1024);
|
||||
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_rendertarget, 10,
|
||||
32 * 1024 * 1024);
|
||||
|
||||
IggySetGDraw(gdraw_funcs);
|
||||
IggySetGDraw(gdraw_funcs);
|
||||
|
||||
postInit();
|
||||
postInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,4 +31,4 @@
|
|||
#include "d3d11_stubs.h"
|
||||
#include "xbox_stubs.h"
|
||||
|
||||
#endif // STUBS_H
|
||||
#endif // STUBS_H
|
||||
|
|
|
|||
|
|
@ -496,7 +496,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
|||
int y0 = 0;
|
||||
// 4J-PB - no hardcore in xbox
|
||||
// if
|
||||
// (minecraft.level.getLevelData().isHardcore()) { y0 = 5;
|
||||
// (minecraft.level.getLevelData().isHardcore()) {
|
||||
// y0 = 5;
|
||||
// }
|
||||
blit(xo, yo, 16 + bg * 9, 9 * 0, 9, 9);
|
||||
if (blink) {
|
||||
|
|
@ -571,7 +572,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
|||
////////////////////////////
|
||||
if (bDisplayGui) {
|
||||
// glDisable(GL_BLEND); 4J - removed - we want
|
||||
//to be able to fade our gui
|
||||
// to be able to fade our gui
|
||||
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,49 +1,44 @@
|
|||
#include "../Platform/stdafx.h"
|
||||
|
||||
std::wstring toLower(const std::wstring& a)
|
||||
{
|
||||
std::wstring out = std::wstring(a);
|
||||
std::transform(out.begin(), out.end(), out.begin(), ::tolower);
|
||||
return out;
|
||||
std::wstring toLower(const std::wstring& a) {
|
||||
std::wstring out = std::wstring(a);
|
||||
std::transform(out.begin(), out.end(), out.begin(), ::tolower);
|
||||
return out;
|
||||
}
|
||||
|
||||
std::wstring trimString(const std::wstring& a)
|
||||
{
|
||||
std::wstring b;
|
||||
int start = (int)a.find_first_not_of(L" \t\n\r");
|
||||
int end = (int)a.find_last_not_of(L" \t\n\r");
|
||||
if( start == std::wstring::npos ) start = 0;
|
||||
if( end == std::wstring::npos ) end = (int)a.size()-1;
|
||||
b = a.substr(start,(end-start)+1);
|
||||
return b;
|
||||
std::wstring trimString(const std::wstring& a) {
|
||||
std::wstring b;
|
||||
int start = (int)a.find_first_not_of(L" \t\n\r");
|
||||
int end = (int)a.find_last_not_of(L" \t\n\r");
|
||||
if (start == std::wstring::npos) start = 0;
|
||||
if (end == std::wstring::npos) end = (int)a.size() - 1;
|
||||
b = a.substr(start, (end - start) + 1);
|
||||
return b;
|
||||
}
|
||||
|
||||
std::wstring replaceAll(const std::wstring& in, const std::wstring& replace, const std::wstring& with)
|
||||
{
|
||||
std::wstring out = in;
|
||||
size_t pos = 0;
|
||||
while( ( pos = out.find(replace, pos) ) != std::wstring::npos )
|
||||
{
|
||||
out.replace( pos, replace.length(), with );
|
||||
pos++;
|
||||
}
|
||||
return out;
|
||||
std::wstring replaceAll(const std::wstring& in, const std::wstring& replace,
|
||||
const std::wstring& with) {
|
||||
std::wstring out = in;
|
||||
size_t pos = 0;
|
||||
while ((pos = out.find(replace, pos)) != std::wstring::npos) {
|
||||
out.replace(pos, replace.length(), with);
|
||||
pos++;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool equalsIgnoreCase(const std::wstring& a, const std::wstring& b)
|
||||
{
|
||||
bool out;
|
||||
std::wstring c = toLower(a);
|
||||
std::wstring d = toLower(b);
|
||||
out = c.compare(d) == 0;
|
||||
return out;
|
||||
bool equalsIgnoreCase(const std::wstring& a, const std::wstring& b) {
|
||||
bool out;
|
||||
std::wstring c = toLower(a);
|
||||
std::wstring d = toLower(b);
|
||||
out = c.compare(d) == 0;
|
||||
return out;
|
||||
}
|
||||
|
||||
std::wstring convStringToWstring(const std::string& converting)
|
||||
{
|
||||
std::wstring converted(converting.length(), L' ');
|
||||
copy(converting.begin(), converting.end(), converted.begin());
|
||||
return converted;
|
||||
std::wstring convStringToWstring(const std::string& converting) {
|
||||
std::wstring converted(converting.length(), L' ');
|
||||
copy(converting.begin(), converting.end(), converted.begin());
|
||||
return converted;
|
||||
}
|
||||
|
||||
std::u16string convWstringToU16string(const std::wstring& converting) {
|
||||
|
|
@ -61,7 +56,7 @@ std::u16string convWstringToU16string(const std::wstring& converting) {
|
|||
if (cp <= 0xFFFF) {
|
||||
// Avoid producing UTF-16 surrogate code points directly
|
||||
if (cp >= 0xD800 && cp <= 0xDFFF) {
|
||||
out.push_back(u'\uFFFD'); // replacement char
|
||||
out.push_back(u'\uFFFD'); // replacement char
|
||||
} else {
|
||||
out.push_back(static_cast<char16_t>(cp));
|
||||
}
|
||||
|
|
@ -70,7 +65,7 @@ std::u16string convWstringToU16string(const std::wstring& converting) {
|
|||
out.push_back(static_cast<char16_t>(0xD800 + (cp >> 10)));
|
||||
out.push_back(static_cast<char16_t>(0xDC00 + (cp & 0x3FF)));
|
||||
} else {
|
||||
out.push_back(u'\uFFFD'); // invalid code point
|
||||
out.push_back(u'\uFFFD'); // invalid code point
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -78,88 +73,85 @@ std::u16string convWstringToU16string(const std::wstring& converting) {
|
|||
return out;
|
||||
}
|
||||
|
||||
// Convert for filename std::wstrings to a straight character pointer for Xbox APIs. The returned string is only valid until
|
||||
// this function is called again, and it isn't thread-safe etc. as I'm just storing the returned name in a local static
|
||||
// to save having to clear it up everywhere this is used.
|
||||
const char *wstringtofilename(const std::wstring& name)
|
||||
{
|
||||
static char buf[256];
|
||||
assert(name.length()<256);
|
||||
for(unsigned int i = 0; i < name.length(); i++ )
|
||||
{
|
||||
wchar_t c = name[i];
|
||||
// Convert for filename std::wstrings to a straight character pointer for Xbox
|
||||
// APIs. The returned string is only valid until this function is called again,
|
||||
// and it isn't thread-safe etc. as I'm just storing the returned name in a
|
||||
// local static to save having to clear it up everywhere this is used.
|
||||
const char* wstringtofilename(const std::wstring& name) {
|
||||
static char buf[256];
|
||||
assert(name.length() < 256);
|
||||
for (unsigned int i = 0; i < name.length(); i++) {
|
||||
wchar_t c = name[i];
|
||||
#if defined __PS3__ || defined __ORBIS__ || defined __linux__
|
||||
if(c=='\\') c='/';
|
||||
if (c == '\\') c = '/';
|
||||
#else
|
||||
if(c=='/') c='\\';
|
||||
if (c == '/') c = '\\';
|
||||
#endif
|
||||
assert(c<128); // Will we have to do any conversion of non-ASCII characters in filenames?
|
||||
buf[i] = (char)c;
|
||||
}
|
||||
buf[name.length()] = 0;
|
||||
return buf;
|
||||
assert(c < 128); // Will we have to do any conversion of non-ASCII
|
||||
// characters in filenames?
|
||||
buf[i] = (char)c;
|
||||
}
|
||||
buf[name.length()] = 0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
std::wstring filenametowstring(const char *name)
|
||||
{
|
||||
return convStringToWstring(name);
|
||||
std::wstring filenametowstring(const char* name) {
|
||||
return convStringToWstring(name);
|
||||
}
|
||||
|
||||
std::vector<std::wstring> &stringSplit(const std::wstring &s, wchar_t delim, std::vector<std::wstring> &elems)
|
||||
{
|
||||
std::vector<std::wstring>& stringSplit(const std::wstring& s, wchar_t delim,
|
||||
std::vector<std::wstring>& elems) {
|
||||
std::wstringstream ss(s);
|
||||
std::wstring item;
|
||||
while(std::getline(ss, item, delim))
|
||||
{
|
||||
while (std::getline(ss, item, delim)) {
|
||||
elems.push_back(item);
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::wstring> stringSplit(const std::wstring &s, wchar_t delim)
|
||||
{
|
||||
std::vector<std::wstring> stringSplit(const std::wstring& s, wchar_t delim) {
|
||||
std::vector<std::wstring> elems;
|
||||
return stringSplit(s, delim, elems);
|
||||
}
|
||||
|
||||
bool BothAreSpaces(wchar_t lhs, wchar_t rhs) { return (lhs == rhs) && (lhs == L' '); }
|
||||
|
||||
void stripWhitespaceForHtml(std::wstring &string, bool bRemoveNewline)
|
||||
{
|
||||
// Strip newline chars
|
||||
if(bRemoveNewline)
|
||||
{
|
||||
string.erase(std::remove(string.begin(), string.end(), '\n'), string.end());
|
||||
string.erase(std::remove(string.begin(), string.end(), '\r'), string.end());
|
||||
}
|
||||
|
||||
string.erase(std::remove(string.begin(), string.end(), '\t'), string.end());
|
||||
|
||||
// Strip duplicate spaces
|
||||
string.erase(std::unique(string.begin(), string.end(), BothAreSpaces), string.end());
|
||||
|
||||
string = trimString(string);
|
||||
bool BothAreSpaces(wchar_t lhs, wchar_t rhs) {
|
||||
return (lhs == rhs) && (lhs == L' ');
|
||||
}
|
||||
|
||||
std::wstring escapeXML(const std::wstring &in)
|
||||
{
|
||||
std::wstring out = in;
|
||||
out = replaceAll(out, L"&", L"&");
|
||||
//out = replaceAll(out, L"\"", L""");
|
||||
//out = replaceAll(out, L"'", L"'");
|
||||
out = replaceAll(out, L"<", L"<");
|
||||
out = replaceAll(out, L">", L">");
|
||||
return out;
|
||||
void stripWhitespaceForHtml(std::wstring& string, bool bRemoveNewline) {
|
||||
// Strip newline chars
|
||||
if (bRemoveNewline) {
|
||||
string.erase(std::remove(string.begin(), string.end(), '\n'),
|
||||
string.end());
|
||||
string.erase(std::remove(string.begin(), string.end(), '\r'),
|
||||
string.end());
|
||||
}
|
||||
|
||||
string.erase(std::remove(string.begin(), string.end(), '\t'), string.end());
|
||||
|
||||
// Strip duplicate spaces
|
||||
string.erase(std::unique(string.begin(), string.end(), BothAreSpaces),
|
||||
string.end());
|
||||
|
||||
string = trimString(string);
|
||||
}
|
||||
|
||||
std::wstring parseXMLSpecials(const std::wstring &in)
|
||||
{
|
||||
std::wstring out = in;
|
||||
out = replaceAll(out, L"&", L"&");
|
||||
//out = replaceAll(out, L"\"", L""");
|
||||
//out = replaceAll(out, L"'", L"'");
|
||||
out = replaceAll(out, L"<", L"<");
|
||||
out = replaceAll(out, L">", L">");
|
||||
return out;
|
||||
std::wstring escapeXML(const std::wstring& in) {
|
||||
std::wstring out = in;
|
||||
out = replaceAll(out, L"&", L"&");
|
||||
// out = replaceAll(out, L"\"", L""");
|
||||
// out = replaceAll(out, L"'", L"'");
|
||||
out = replaceAll(out, L"<", L"<");
|
||||
out = replaceAll(out, L">", L">");
|
||||
return out;
|
||||
}
|
||||
|
||||
std::wstring parseXMLSpecials(const std::wstring& in) {
|
||||
std::wstring out = in;
|
||||
out = replaceAll(out, L"&", L"&");
|
||||
// out = replaceAll(out, L"\"", L""");
|
||||
// out = replaceAll(out, L"'", L"'");
|
||||
out = replaceAll(out, L"<", L"<");
|
||||
out = replaceAll(out, L">", L">");
|
||||
return out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,29 @@
|
|||
#pragma once
|
||||
//using namespace stdtd;
|
||||
// using namespace stdtd;
|
||||
|
||||
std::wstring toLower(const std::wstring& a);
|
||||
std::wstring trimString(const std::wstring& a);
|
||||
std::wstring replaceAll(const std::wstring& in, const std::wstring& replace, const std::wstring& with);
|
||||
std::wstring replaceAll(const std::wstring& in, const std::wstring& replace,
|
||||
const std::wstring& with);
|
||||
|
||||
bool equalsIgnoreCase(const std::wstring& a, const std::wstring& b);
|
||||
// 4J-PB - for use in the ::toString
|
||||
template <class T> std::wstring _toString(T t)
|
||||
{
|
||||
std::wostringstream oss;
|
||||
oss << std::dec << t;
|
||||
return oss.str();
|
||||
// 4J-PB - for use in the ::toString
|
||||
template <class T>
|
||||
std::wstring _toString(T t) {
|
||||
std::wostringstream oss;
|
||||
oss << std::dec << t;
|
||||
return oss.str();
|
||||
}
|
||||
template <class T> T _fromString(const std::wstring& s)
|
||||
{
|
||||
std::wistringstream stream (s);
|
||||
template <class T>
|
||||
T _fromString(const std::wstring& s) {
|
||||
std::wistringstream stream(s);
|
||||
T t;
|
||||
stream >> t;
|
||||
return t;
|
||||
}
|
||||
template <class T> T _fromHEXString(const std::wstring& s)
|
||||
{
|
||||
std::wistringstream stream (s);
|
||||
template <class T>
|
||||
T _fromHEXString(const std::wstring& s) {
|
||||
std::wistringstream stream(s);
|
||||
T t;
|
||||
stream >> std::hex >> t;
|
||||
return t;
|
||||
|
|
@ -30,12 +31,13 @@ template <class T> T _fromHEXString(const std::wstring& s)
|
|||
|
||||
std::wstring convStringToWstring(const std::string& converting);
|
||||
std::u16string convWstringToU16string(const std::wstring& converting);
|
||||
const char *wstringtofilename(const std::wstring& name);
|
||||
std::wstring filenametowstring(const char *name);
|
||||
const char* wstringtofilename(const std::wstring& name);
|
||||
std::wstring filenametowstring(const char* name);
|
||||
|
||||
std::vector<std::wstring> &stringSplit(const std::wstring &s, wchar_t delim, std::vector<std::wstring> &elems);
|
||||
std::vector<std::wstring> stringSplit(const std::wstring &s, wchar_t delim);
|
||||
std::vector<std::wstring>& stringSplit(const std::wstring& s, wchar_t delim,
|
||||
std::vector<std::wstring>& elems);
|
||||
std::vector<std::wstring> stringSplit(const std::wstring& s, wchar_t delim);
|
||||
|
||||
void stripWhitespaceForHtml(std::wstring &string, bool bRemoveNewline=true);
|
||||
std::wstring escapeXML(const std::wstring &in);
|
||||
std::wstring parseXMLSpecials(const std::wstring &in);
|
||||
void stripWhitespaceForHtml(std::wstring& string, bool bRemoveNewline = true);
|
||||
std::wstring escapeXML(const std::wstring& in);
|
||||
std::wstring parseXMLSpecials(const std::wstring& in);
|
||||
|
|
|
|||
Loading…
Reference in a new issue