Switch from std::string to String/ByteString in most of the code
Also switch SimulationData from weird arrays to std::vector
This commit is contained in:
parent
4912674bfe
commit
ff27d69424
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
|
|
||||||
std::string format::URLEncode(std::string source)
|
ByteString format::URLEncode(ByteString source)
|
||||||
{
|
{
|
||||||
char * src = (char *)source.c_str();
|
char * src = (char *)source.c_str();
|
||||||
char * dst = new char[(source.length()*3)+2];
|
char * dst = new char[(source.length()*3)+2];
|
||||||
@ -33,12 +33,12 @@ std::string format::URLEncode(std::string source)
|
|||||||
}
|
}
|
||||||
*d = 0;
|
*d = 0;
|
||||||
|
|
||||||
std::string finalString(dst);
|
ByteString finalString(dst);
|
||||||
delete[] dst;
|
delete[] dst;
|
||||||
return finalString;
|
return finalString;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string format::UnixtimeToDate(time_t unixtime, std::string dateFormat)
|
ByteString format::UnixtimeToDate(time_t unixtime, ByteString dateFormat)
|
||||||
{
|
{
|
||||||
struct tm * timeData;
|
struct tm * timeData;
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
@ -46,10 +46,10 @@ std::string format::UnixtimeToDate(time_t unixtime, std::string dateFormat)
|
|||||||
timeData = localtime(&unixtime);
|
timeData = localtime(&unixtime);
|
||||||
|
|
||||||
strftime(buffer, 128, dateFormat.c_str(), timeData);
|
strftime(buffer, 128, dateFormat.c_str(), timeData);
|
||||||
return std::string(buffer);
|
return ByteString(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string format::UnixtimeToDateMini(time_t unixtime)
|
ByteString format::UnixtimeToDateMini(time_t unixtime)
|
||||||
{
|
{
|
||||||
time_t currentTime = time(NULL);
|
time_t currentTime = time(NULL);
|
||||||
struct tm currentTimeData = *localtime(¤tTime);
|
struct tm currentTimeData = *localtime(¤tTime);
|
||||||
@ -69,7 +69,7 @@ std::string format::UnixtimeToDateMini(time_t unixtime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string format::CleanString(std::string dirtyString, bool ascii, bool color, bool newlines, bool numeric)
|
String format::CleanString(String dirtyString, bool ascii, bool color, bool newlines, bool numeric)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < dirtyString.size(); i++)
|
for (size_t i = 0; i < dirtyString.size(); i++)
|
||||||
{
|
{
|
||||||
@ -226,7 +226,7 @@ struct PNGChunk
|
|||||||
|
|
||||||
//char[4] CRC();
|
//char[4] CRC();
|
||||||
|
|
||||||
PNGChunk(int length, std::string name)
|
PNGChunk(int length, ByteString name)
|
||||||
{
|
{
|
||||||
if (name.length()!=4)
|
if (name.length()!=4)
|
||||||
throw std::runtime_error("Invalid chunk name");
|
throw std::runtime_error("Invalid chunk name");
|
||||||
|
32
src/Format.h
32
src/Format.h
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sstream>
|
#include "common/String.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class VideoBuffer;
|
class VideoBuffer;
|
||||||
@ -9,24 +9,38 @@ namespace format
|
|||||||
{
|
{
|
||||||
const static char hex[] = "0123456789ABCDEF";
|
const static char hex[] = "0123456789ABCDEF";
|
||||||
|
|
||||||
template <typename T> std::string NumberToString(T number)
|
template <typename T> ByteString NumberToByteString(T number)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
ByteString::Stream ss;
|
||||||
ss << number;
|
ss << number;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> T StringToNumber(const std::string & text)
|
template <typename T> String NumberToString(T number)
|
||||||
{
|
{
|
||||||
std::stringstream ss(text);
|
String::Stream ss;
|
||||||
|
ss << number;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> T ByteStringToNumber(const ByteString & text)
|
||||||
|
{
|
||||||
|
ByteString::Stream ss(text);
|
||||||
T number;
|
T number;
|
||||||
return (ss >> number)?number:0;
|
return (ss >> number)?number:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string URLEncode(std::string value);
|
template <typename T> T StringToNumber(const String & text)
|
||||||
std::string UnixtimeToDate(time_t unixtime, std::string dateFomat = "%d %b %Y");
|
{
|
||||||
std::string UnixtimeToDateMini(time_t unixtime);
|
String::Stream ss(text);
|
||||||
std::string CleanString(std::string dirtyString, bool ascii, bool color, bool newlines, bool numeric = false);
|
T number;
|
||||||
|
return (ss >> number)?number:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteString URLEncode(ByteString value);
|
||||||
|
ByteString UnixtimeToDate(time_t unixtime, ByteString dateFomat = "%d %b %Y");
|
||||||
|
ByteString UnixtimeToDateMini(time_t unixtime);
|
||||||
|
String CleanString(String dirtyString, bool ascii, bool color, bool newlines, bool numeric = false);
|
||||||
std::vector<char> VideoBufferToPNG(const VideoBuffer & vidBuf);
|
std::vector<char> VideoBufferToPNG(const VideoBuffer & vidBuf);
|
||||||
std::vector<char> VideoBufferToBMP(const VideoBuffer & vidBuf);
|
std::vector<char> VideoBufferToBMP(const VideoBuffer & vidBuf);
|
||||||
std::vector<char> VideoBufferToPPM(const VideoBuffer & vidBuf);
|
std::vector<char> VideoBufferToPPM(const VideoBuffer & vidBuf);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
//Linear interpolation
|
//Linear interpolation
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
namespace Platform
|
namespace Platform
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string ExecutableName()
|
ByteString ExecutableName()
|
||||||
{
|
{
|
||||||
std::string ret;
|
ByteString ret;
|
||||||
#if defined(WIN)
|
#if defined(WIN)
|
||||||
char *name = (char *)malloc(64);
|
char *name = (char *)malloc(64);
|
||||||
DWORD max = 64, res;
|
DWORD max = 64, res;
|
||||||
@ -73,7 +73,7 @@ std::string ExecutableName()
|
|||||||
|
|
||||||
void DoRestart()
|
void DoRestart()
|
||||||
{
|
{
|
||||||
std::string exename = ExecutableName();
|
ByteString exename = ExecutableName();
|
||||||
if (exename.length())
|
if (exename.length())
|
||||||
{
|
{
|
||||||
#ifdef WIN
|
#ifdef WIN
|
||||||
@ -85,7 +85,7 @@ void DoRestart()
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenURI(std::string uri)
|
void OpenURI(ByteString uri)
|
||||||
{
|
{
|
||||||
#if defined(WIN)
|
#if defined(WIN)
|
||||||
ShellExecute(0, "OPEN", uri.c_str(), NULL, NULL, 0);
|
ShellExecute(0, "OPEN", uri.c_str(), NULL, NULL, 0);
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#ifndef PLATFORM_H
|
#ifndef PLATFORM_H
|
||||||
#define PLATFORM_H
|
#define PLATFORM_H
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
|
|
||||||
namespace Platform
|
namespace Platform
|
||||||
{
|
{
|
||||||
std::string ExecutableName();
|
ByteString ExecutableName();
|
||||||
void DoRestart();
|
void DoRestart();
|
||||||
|
|
||||||
void OpenURI(std::string uri);
|
void OpenURI(ByteString uri);
|
||||||
|
|
||||||
void Millisleep(long int t);
|
void Millisleep(long int t);
|
||||||
long unsigned int GetTime();
|
long unsigned int GetTime();
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
|
||||||
|
|
||||||
void EngineProcess();
|
void EngineProcess();
|
||||||
void ClipboardPush(std::string text);
|
void ClipboardPush(ByteString text);
|
||||||
std::string ClipboardPull();
|
ByteString ClipboardPull();
|
||||||
int GetModifiers();
|
int GetModifiers();
|
||||||
bool LoadWindowPosition(int scale);
|
bool LoadWindowPosition(int scale);
|
||||||
void SetCursorEnabled(int enabled);
|
void SetCursorEnabled(int enabled);
|
||||||
|
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "common/String.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
#include "gui/interface/Engine.h"
|
#include "gui/interface/Engine.h"
|
||||||
@ -18,16 +17,16 @@
|
|||||||
|
|
||||||
|
|
||||||
void EngineProcess() {}
|
void EngineProcess() {}
|
||||||
void ClipboardPush(std::string) {}
|
void ClipboardPush(ByteString) {}
|
||||||
std::string ClipboardPull() { return ""; }
|
ByteString ClipboardPull() { return ""; }
|
||||||
int GetModifiers() { return 0; }
|
int GetModifiers() { return 0; }
|
||||||
void SetCursorEnabled(int enabled) {}
|
void SetCursorEnabled(int enabled) {}
|
||||||
unsigned int GetTicks() { return 0; }
|
unsigned int GetTicks() { return 0; }
|
||||||
|
|
||||||
void readFile(std::string filename, std::vector<char> & storage)
|
void readFile(ByteString filename, std::vector<char> & storage)
|
||||||
{
|
{
|
||||||
std::ifstream fileStream;
|
std::ifstream fileStream;
|
||||||
fileStream.open(std::string(filename).c_str(), std::ios::binary);
|
fileStream.open(filename.c_str(), std::ios::binary);
|
||||||
if(fileStream.is_open())
|
if(fileStream.is_open())
|
||||||
{
|
{
|
||||||
fileStream.seekg(0, std::ios::end);
|
fileStream.seekg(0, std::ios::end);
|
||||||
@ -45,10 +44,10 @@ void readFile(std::string filename, std::vector<char> & storage)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeFile(std::string filename, std::vector<char> & fileData)
|
void writeFile(ByteString filename, std::vector<char> & fileData)
|
||||||
{
|
{
|
||||||
std::ofstream fileStream;
|
std::ofstream fileStream;
|
||||||
fileStream.open(std::string(filename).c_str(), std::ios::binary);
|
fileStream.open(filename.c_str(), std::ios::binary);
|
||||||
if(fileStream.is_open())
|
if(fileStream.is_open())
|
||||||
{
|
{
|
||||||
fileStream.write(&fileData[0], fileData.size());
|
fileStream.write(&fileData[0], fileData.size());
|
||||||
@ -59,13 +58,13 @@ void writeFile(std::string filename, std::vector<char> & fileData)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ui::Engine * engine;
|
ui::Engine * engine;
|
||||||
std::string outputPrefix, inputFilename;
|
ByteString outputPrefix, inputFilename;
|
||||||
std::vector<char> inputFile;
|
std::vector<char> inputFile;
|
||||||
std::string ppmFilename, ptiFilename, ptiSmallFilename, pngFilename, pngSmallFilename;
|
ByteString ppmFilename, ptiFilename, ptiSmallFilename, pngFilename, pngSmallFilename;
|
||||||
std::vector<char> ppmFile, ptiFile, ptiSmallFile, pngFile, pngSmallFile;
|
std::vector<char> ppmFile, ptiFile, ptiSmallFile, pngFile, pngSmallFile;
|
||||||
|
|
||||||
inputFilename = std::string(argv[1]);
|
inputFilename = argv[1];
|
||||||
outputPrefix = std::string(argv[2]);
|
outputPrefix = argv[2];
|
||||||
|
|
||||||
ppmFilename = outputPrefix+".ppm";
|
ppmFilename = outputPrefix+".ppm";
|
||||||
ptiFilename = outputPrefix+".pti";
|
ptiFilename = outputPrefix+".pti";
|
||||||
@ -88,7 +87,7 @@ int main(int argc, char *argv[])
|
|||||||
catch (ParseException e)
|
catch (ParseException e)
|
||||||
{
|
{
|
||||||
//Render the save again later or something? I don't know
|
//Render the save again later or something? I don't know
|
||||||
if (e.what() == "Save from newer version")
|
if (ByteString(e.what()).FromUtf8() == "Save from newer version")
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifdef USE_SDL
|
#ifdef USE_SDL
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#ifdef WIN
|
#ifdef WIN
|
||||||
@ -18,9 +18,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include "common/String.h"
|
||||||
#include <string>
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "common/String.h"
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
#if defined(LIN)
|
#if defined(LIN)
|
||||||
#include "icon.h"
|
#include "icon.h"
|
||||||
@ -68,7 +68,7 @@ SDL_SysWMinfo sdl_wminfo;
|
|||||||
Atom XA_CLIPBOARD, XA_TARGETS, XA_UTF8_STRING;
|
Atom XA_CLIPBOARD, XA_TARGETS, XA_UTF8_STRING;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string clipboardText = "";
|
ByteString clipboardText = "";
|
||||||
|
|
||||||
int desktopWidth = 1280, desktopHeight = 1024;
|
int desktopWidth = 1280, desktopHeight = 1024;
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ SDL_Surface * sdl_scrn;
|
|||||||
int scale = 1;
|
int scale = 1;
|
||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
|
|
||||||
void ClipboardPush(std::string text)
|
void ClipboardPush(ByteString text)
|
||||||
{
|
{
|
||||||
clipboardText = text;
|
clipboardText = text;
|
||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
@ -110,11 +110,11 @@ void ClipboardPush(std::string text)
|
|||||||
|
|
||||||
void EventProcess(SDL_Event event);
|
void EventProcess(SDL_Event event);
|
||||||
|
|
||||||
std::string ClipboardPull()
|
ByteString ClipboardPull()
|
||||||
{
|
{
|
||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
const char *text = readClipboard();
|
const char *text = readClipboard();
|
||||||
return text ? std::string(text) : "";
|
return text ? ByteString(text).FromUtf8() : "";
|
||||||
#elif defined(WIN)
|
#elif defined(WIN)
|
||||||
if (OpenClipboard(NULL))
|
if (OpenClipboard(NULL))
|
||||||
{
|
{
|
||||||
@ -125,10 +125,10 @@ std::string ClipboardPull()
|
|||||||
glbuffer = (char*)GlobalLock(cbuffer);
|
glbuffer = (char*)GlobalLock(cbuffer);
|
||||||
GlobalUnlock(cbuffer);
|
GlobalUnlock(cbuffer);
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
return glbuffer ? std::string(glbuffer) : "";
|
return glbuffer ? ByteString(glbuffer) : "";
|
||||||
}
|
}
|
||||||
#elif defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
|
#elif defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
|
||||||
std::string text = "";
|
ByteString text = "";
|
||||||
Window selectionOwner;
|
Window selectionOwner;
|
||||||
sdl_wminfo.info.x11.lock_func();
|
sdl_wminfo.info.x11.lock_func();
|
||||||
selectionOwner = XGetSelectionOwner(sdl_wminfo.info.x11.display, XA_CLIPBOARD);
|
selectionOwner = XGetSelectionOwner(sdl_wminfo.info.x11.display, XA_CLIPBOARD);
|
||||||
@ -168,7 +168,7 @@ std::string ClipboardPull()
|
|||||||
result = XGetWindowProperty(sdl_wminfo.info.x11.display, sdl_wminfo.info.x11.window, XA_CLIPBOARD, 0, bytesLeft, 0, AnyPropertyType, &type, &format, &len, &bytesLeft, &data);
|
result = XGetWindowProperty(sdl_wminfo.info.x11.display, sdl_wminfo.info.x11.window, XA_CLIPBOARD, 0, bytesLeft, 0, AnyPropertyType, &type, &format, &len, &bytesLeft, &data);
|
||||||
if (result == Success)
|
if (result == Success)
|
||||||
{
|
{
|
||||||
text = data ? (const char*)data : "";
|
text = data ? ByteString((char const *)data) : "";
|
||||||
XFree(data);
|
XFree(data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -526,9 +526,9 @@ unsigned int GetTicks()
|
|||||||
return SDL_GetTicks();
|
return SDL_GetTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::string> readArguments(int argc, char * argv[])
|
std::map<ByteString, ByteString> readArguments(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
std::map<std::string, std::string> arguments;
|
std::map<ByteString, ByteString> arguments;
|
||||||
|
|
||||||
//Defaults
|
//Defaults
|
||||||
arguments["scale"] = "";
|
arguments["scale"] = "";
|
||||||
@ -545,12 +545,12 @@ std::map<std::string, std::string> readArguments(int argc, char * argv[])
|
|||||||
{
|
{
|
||||||
if (!strncmp(argv[i], "scale:", 6) && argv[i]+6)
|
if (!strncmp(argv[i], "scale:", 6) && argv[i]+6)
|
||||||
{
|
{
|
||||||
arguments["scale"] = std::string(argv[i]+6);
|
arguments["scale"] = argv[i]+6;
|
||||||
}
|
}
|
||||||
else if (!strncmp(argv[i], "proxy:", 6))
|
else if (!strncmp(argv[i], "proxy:", 6))
|
||||||
{
|
{
|
||||||
if(argv[i]+6)
|
if(argv[i]+6)
|
||||||
arguments["proxy"] = std::string(argv[i]+6);
|
arguments["proxy"] = argv[i]+6;
|
||||||
else
|
else
|
||||||
arguments["proxy"] = "false";
|
arguments["proxy"] = "false";
|
||||||
}
|
}
|
||||||
@ -572,17 +572,17 @@ std::map<std::string, std::string> readArguments(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
else if (!strncmp(argv[i], "open", 5) && i+1<argc)
|
else if (!strncmp(argv[i], "open", 5) && i+1<argc)
|
||||||
{
|
{
|
||||||
arguments["open"] = std::string(argv[i+1]);;
|
arguments["open"] = argv[i+1];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else if (!strncmp(argv[i], "ddir", 5) && i+1<argc)
|
else if (!strncmp(argv[i], "ddir", 5) && i+1<argc)
|
||||||
{
|
{
|
||||||
arguments["ddir"] = std::string(argv[i+1]);
|
arguments["ddir"] = argv[i+1];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else if (!strncmp(argv[i], "ptsave", 7) && i+1<argc)
|
else if (!strncmp(argv[i], "ptsave", 7) && i+1<argc)
|
||||||
{
|
{
|
||||||
arguments["ptsave"] = std::string(argv[i+1]);
|
arguments["ptsave"] = argv[i+1];
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -753,7 +753,7 @@ void EventProcess(SDL_Event event)
|
|||||||
|
|
||||||
void DoubleScreenDialog()
|
void DoubleScreenDialog()
|
||||||
{
|
{
|
||||||
std::stringstream message;
|
String::Stream message;
|
||||||
message << "Switching to double size mode since your screen was determined to be large enough: ";
|
message << "Switching to double size mode since your screen was determined to be large enough: ";
|
||||||
message << desktopWidth << "x" << desktopHeight << " detected, " << WINDOWW*2 << "x" << WINDOWH*2 << " required";
|
message << desktopWidth << "x" << desktopHeight << " detected, " << WINDOWW*2 << "x" << WINDOWH*2 << " required";
|
||||||
message << "\nTo undo this, hit Cancel. You can toggle double size mode in settings at any time.";
|
message << "\nTo undo this, hit Cancel. You can toggle double size mode in settings at any time.";
|
||||||
@ -916,28 +916,28 @@ bool SaveWindowPosition()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void BlueScreen(const char * detailMessage){
|
void BlueScreen(String detailMessage){
|
||||||
ui::Engine * engine = &ui::Engine::Ref();
|
ui::Engine * engine = &ui::Engine::Ref();
|
||||||
engine->g->fillrect(0, 0, engine->GetWidth(), engine->GetHeight(), 17, 114, 169, 210);
|
engine->g->fillrect(0, 0, engine->GetWidth(), engine->GetHeight(), 17, 114, 169, 210);
|
||||||
|
|
||||||
std::string errorTitle = "ERROR";
|
String errorTitle = "ERROR";
|
||||||
std::string errorDetails = "Details: " + std::string(detailMessage);
|
String errorDetails = "Details: " + detailMessage;
|
||||||
std::string errorHelp = "An unrecoverable fault has occurred, please report the error by visiting the website below\n"
|
String errorHelp = "An unrecoverable fault has occurred, please report the error by visiting the website below\n"
|
||||||
"http://" SERVER;
|
"http://" SERVER;
|
||||||
int currentY = 0, width, height;
|
int currentY = 0, width, height;
|
||||||
int errorWidth = 0;
|
int errorWidth = 0;
|
||||||
Graphics::textsize(errorHelp.c_str(), errorWidth, height);
|
Graphics::textsize(errorHelp, errorWidth, height);
|
||||||
|
|
||||||
engine->g->drawtext((engine->GetWidth()/2)-(errorWidth/2), ((engine->GetHeight()/2)-100) + currentY, errorTitle.c_str(), 255, 255, 255, 255);
|
engine->g->drawtext((engine->GetWidth()/2)-(errorWidth/2), ((engine->GetHeight()/2)-100) + currentY, errorTitle.c_str(), 255, 255, 255, 255);
|
||||||
Graphics::textsize(errorTitle.c_str(), width, height);
|
Graphics::textsize(errorTitle, width, height);
|
||||||
currentY += height + 4;
|
currentY += height + 4;
|
||||||
|
|
||||||
engine->g->drawtext((engine->GetWidth()/2)-(errorWidth/2), ((engine->GetHeight()/2)-100) + currentY, errorDetails.c_str(), 255, 255, 255, 255);
|
engine->g->drawtext((engine->GetWidth()/2)-(errorWidth/2), ((engine->GetHeight()/2)-100) + currentY, errorDetails.c_str(), 255, 255, 255, 255);
|
||||||
Graphics::textsize(errorTitle.c_str(), width, height);
|
Graphics::textsize(errorTitle, width, height);
|
||||||
currentY += height + 4;
|
currentY += height + 4;
|
||||||
|
|
||||||
engine->g->drawtext((engine->GetWidth()/2)-(errorWidth/2), ((engine->GetHeight()/2)-100) + currentY, errorHelp.c_str(), 255, 255, 255, 255);
|
engine->g->drawtext((engine->GetWidth()/2)-(errorWidth/2), ((engine->GetHeight()/2)-100) + currentY, errorHelp.c_str(), 255, 255, 255, 255);
|
||||||
Graphics::textsize(errorTitle.c_str(), width, height);
|
Graphics::textsize(errorTitle, width, height);
|
||||||
currentY += height + 4;
|
currentY += height + 4;
|
||||||
|
|
||||||
//Death loop
|
//Death loop
|
||||||
@ -985,7 +985,7 @@ int main(int argc, char * argv[])
|
|||||||
currentHeight = WINDOWH;
|
currentHeight = WINDOWH;
|
||||||
|
|
||||||
|
|
||||||
std::map<std::string, std::string> arguments = readArguments(argc, argv);
|
std::map<ByteString, ByteString> arguments = readArguments(argc, argv);
|
||||||
|
|
||||||
if(arguments["ddir"].length())
|
if(arguments["ddir"].length())
|
||||||
#ifdef WIN
|
#ifdef WIN
|
||||||
@ -1009,11 +1009,11 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
if(arguments["scale"].length())
|
if(arguments["scale"].length())
|
||||||
{
|
{
|
||||||
tempScale = format::StringToNumber<int>(arguments["scale"]);
|
tempScale = format::ByteStringToNumber<int>(arguments["scale"]);
|
||||||
Client::Ref().SetPref("Scale", tempScale);
|
Client::Ref().SetPref("Scale", tempScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string proxyString = "";
|
ByteString proxyString = "";
|
||||||
if(arguments["proxy"].length())
|
if(arguments["proxy"].length())
|
||||||
{
|
{
|
||||||
if(arguments["proxy"] == "false")
|
if(arguments["proxy"] == "false")
|
||||||
@ -1029,7 +1029,7 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
else if(Client::Ref().GetPrefString("Proxy", "").length())
|
else if(Client::Ref().GetPrefString("Proxy", "").length())
|
||||||
{
|
{
|
||||||
proxyString = (Client::Ref().GetPrefString("Proxy", ""));
|
proxyString = (Client::Ref().GetPrefByteString("Proxy", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
Client::Ref().Initialise(proxyString);
|
Client::Ref().Initialise(proxyString);
|
||||||
@ -1140,7 +1140,7 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
catch(std::exception & e)
|
catch(std::exception & e)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error", "Could not open save file:\n"+std::string(e.what())) ;
|
new ErrorMessage("Error", "Could not open save file:\n" + ByteString(e.what()).FromUtf8()) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1163,16 +1163,16 @@ int main(int argc, char * argv[])
|
|||||||
else
|
else
|
||||||
blit(engine->g->vid);
|
blit(engine->g->vid);
|
||||||
#endif
|
#endif
|
||||||
std::string ptsaveArg = arguments["ptsave"];
|
ByteString ptsaveArg = arguments["ptsave"];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (ptsaveArg.find("ptsave:"))
|
if (ptsaveArg.find("ptsave:"))
|
||||||
throw std::runtime_error("Invalid save link");
|
throw std::runtime_error("Invalid save link");
|
||||||
|
|
||||||
std::string saveIdPart = "";
|
ByteString saveIdPart = "";
|
||||||
int saveId;
|
int saveId;
|
||||||
size_t hashPos = ptsaveArg.find('#');
|
size_t hashPos = ptsaveArg.find('#');
|
||||||
if (hashPos != std::string::npos)
|
if (hashPos != ByteString::npos)
|
||||||
{
|
{
|
||||||
saveIdPart = ptsaveArg.substr(7, hashPos-7);
|
saveIdPart = ptsaveArg.substr(7, hashPos-7);
|
||||||
}
|
}
|
||||||
@ -1185,7 +1185,7 @@ int main(int argc, char * argv[])
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cout << "Got Ptsave: id: " << saveIdPart << std::endl;
|
std::cout << "Got Ptsave: id: " << saveIdPart << std::endl;
|
||||||
#endif
|
#endif
|
||||||
saveId = format::StringToNumber<int>(saveIdPart);
|
saveId = format::ByteStringToNumber<int>(saveIdPart);
|
||||||
if (!saveId)
|
if (!saveId)
|
||||||
throw std::runtime_error("Invalid Save ID");
|
throw std::runtime_error("Invalid Save ID");
|
||||||
|
|
||||||
@ -1194,7 +1194,7 @@ int main(int argc, char * argv[])
|
|||||||
throw std::runtime_error("Could not load save info");
|
throw std::runtime_error("Could not load save info");
|
||||||
std::vector<unsigned char> saveData = Client::Ref().GetSaveData(saveId, 0);
|
std::vector<unsigned char> saveData = Client::Ref().GetSaveData(saveId, 0);
|
||||||
if (!saveData.size())
|
if (!saveData.size())
|
||||||
throw std::runtime_error("Could not load save\n" + Client::Ref().GetLastError());
|
throw std::runtime_error(("Could not load save\n" + Client::Ref().GetLastError()).ToUtf8());
|
||||||
GameSave * newGameSave = new GameSave(saveData);
|
GameSave * newGameSave = new GameSave(saveData);
|
||||||
newSave->SetGameSave(newGameSave);
|
newSave->SetGameSave(newGameSave);
|
||||||
|
|
||||||
@ -1203,7 +1203,7 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
catch (std::exception & e)
|
catch (std::exception & e)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error", e.what());
|
new ErrorMessage("Error", ByteString(e.what()).FromUtf8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
// returns 1 on failure, 0 on success
|
// returns 1 on failure, 0 on success
|
||||||
int update_start(char *data, unsigned int len)
|
int update_start(char *data, unsigned int len)
|
||||||
{
|
{
|
||||||
std::string exeName = Platform::ExecutableName(), updName;
|
ByteString exeName = Platform::ExecutableName(), updName;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if (!exeName.length())
|
if (!exeName.length())
|
||||||
@ -34,7 +34,7 @@ int update_start(char *data, unsigned int len)
|
|||||||
|
|
||||||
#ifdef WIN
|
#ifdef WIN
|
||||||
updName = exeName;
|
updName = exeName;
|
||||||
std::string extension = exeName.substr(exeName.length() - 4);
|
ByteString extension = exeName.substr(exeName.length() - 4);
|
||||||
if (extension == ".exe")
|
if (extension == ".exe")
|
||||||
updName = exeName.substr(0, exeName.length() - 4);
|
updName = exeName.substr(0, exeName.length() - 4);
|
||||||
updName = updName + "_upd.exe";
|
updName = updName + "_upd.exe";
|
||||||
@ -95,7 +95,7 @@ int update_start(char *data, unsigned int len)
|
|||||||
int update_finish()
|
int update_finish()
|
||||||
{
|
{
|
||||||
#ifdef WIN
|
#ifdef WIN
|
||||||
std::string exeName = Platform::ExecutableName(), updName;
|
ByteString exeName = Platform::ExecutableName(), updName;
|
||||||
int timeout = 5, err;
|
int timeout = 5, err;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -103,7 +103,7 @@ int update_finish()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
updName = exeName;
|
updName = exeName;
|
||||||
std::string extension = exeName.substr(exeName.length() - 4);
|
ByteString extension = exeName.substr(exeName.length() - 4);
|
||||||
if (extension == ".exe")
|
if (extension == ".exe")
|
||||||
updName = exeName.substr(0, exeName.length() - 4);
|
updName = exeName.substr(0, exeName.length() - 4);
|
||||||
updName = updName + "_upd.exe";
|
updName = updName + "_upd.exe";
|
||||||
@ -122,7 +122,7 @@ int update_finish()
|
|||||||
#endif
|
#endif
|
||||||
// Old versions of powder toy name their update files with _update.exe, delete that upgrade file here
|
// Old versions of powder toy name their update files with _update.exe, delete that upgrade file here
|
||||||
updName = exeName;
|
updName = exeName;
|
||||||
std::string extension = exeName.substr(exeName.length() - 4);
|
ByteString extension = exeName.substr(exeName.length() - 4);
|
||||||
if (extension == ".exe")
|
if (extension == ".exe")
|
||||||
updName = exeName.substr(0, exeName.length() - 4);
|
updName = exeName.substr(0, exeName.length() - 4);
|
||||||
updName = updName + "_update.exe";
|
updName = updName + "_update.exe";
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
#include "common/String.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "common/Singleton.h"
|
#include "common/Singleton.h"
|
||||||
|
|
||||||
@ -34,24 +35,24 @@ class UpdateInfo
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum BuildType { Stable, Beta, Snapshot };
|
enum BuildType { Stable, Beta, Snapshot };
|
||||||
std::string File;
|
ByteString File;
|
||||||
std::string Changelog;
|
String Changelog;
|
||||||
int Major;
|
int Major;
|
||||||
int Minor;
|
int Minor;
|
||||||
int Build;
|
int Build;
|
||||||
int Time;
|
int Time;
|
||||||
BuildType Type;
|
BuildType Type;
|
||||||
UpdateInfo() : File(""), Changelog(""), Major(0), Minor(0), Build(0), Time(0), Type(Stable) {}
|
UpdateInfo() : File(""), Changelog(""), Major(0), Minor(0), Build(0), Time(0), Type(Stable) {}
|
||||||
UpdateInfo(int major, int minor, int build, std::string file, std::string changelog, BuildType type) : File(file), Changelog(changelog), Major(major), Minor(minor), Build(build), Time(0), Type(type) {}
|
UpdateInfo(int major, int minor, int build, ByteString file, String changelog, BuildType type) : File(file), Changelog(changelog), Major(major), Minor(minor), Build(build), Time(0), Type(type) {}
|
||||||
UpdateInfo(int time, std::string file, std::string changelog, BuildType type) : File(file), Changelog(changelog), Major(0), Minor(0), Build(0), Time(time), Type(type) {}
|
UpdateInfo(int time, ByteString file, String changelog, BuildType type) : File(file), Changelog(changelog), Major(0), Minor(0), Build(0), Time(time), Type(type) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class RequestListener;
|
class RequestListener;
|
||||||
class ClientListener;
|
class ClientListener;
|
||||||
class Client: public Singleton<Client> {
|
class Client: public Singleton<Client> {
|
||||||
private:
|
private:
|
||||||
std::string messageOfTheDay;
|
String messageOfTheDay;
|
||||||
std::vector<std::pair<std::string, std::string> > serverNotifications;
|
std::vector<std::pair<String, ByteString> > serverNotifications;
|
||||||
|
|
||||||
void * versionCheckRequest;
|
void * versionCheckRequest;
|
||||||
void * alternateVersionCheckRequest;
|
void * alternateVersionCheckRequest;
|
||||||
@ -59,10 +60,10 @@ private:
|
|||||||
bool updateAvailable;
|
bool updateAvailable;
|
||||||
UpdateInfo updateInfo;
|
UpdateInfo updateInfo;
|
||||||
|
|
||||||
std::string lastError;
|
String lastError;
|
||||||
bool firstRun;
|
bool firstRun;
|
||||||
|
|
||||||
std::list<std::string> stampIDs;
|
std::list<ByteString> stampIDs;
|
||||||
unsigned lastStampTime;
|
unsigned lastStampTime;
|
||||||
int lastStampName;
|
int lastStampName;
|
||||||
|
|
||||||
@ -75,16 +76,16 @@ private:
|
|||||||
void * activeThumbRequests[IMGCONNS];
|
void * activeThumbRequests[IMGCONNS];
|
||||||
int activeThumbRequestTimes[IMGCONNS];
|
int activeThumbRequestTimes[IMGCONNS];
|
||||||
int activeThumbRequestCompleteTimes[IMGCONNS];
|
int activeThumbRequestCompleteTimes[IMGCONNS];
|
||||||
std::string activeThumbRequestIDs[IMGCONNS];
|
ByteString activeThumbRequestIDs[IMGCONNS];
|
||||||
void notifyUpdateAvailable();
|
void notifyUpdateAvailable();
|
||||||
void notifyAuthUserChanged();
|
void notifyAuthUserChanged();
|
||||||
void notifyMessageOfTheDay();
|
void notifyMessageOfTheDay();
|
||||||
void notifyNewNotification(std::pair<std::string, std::string> notification);
|
void notifyNewNotification(std::pair<String, ByteString> notification);
|
||||||
|
|
||||||
// internal preferences handling
|
// internal preferences handling
|
||||||
Json::Value preferences;
|
Json::Value preferences;
|
||||||
Json::Value GetPref(Json::Value root, std::string prop, Json::Value defaultValue = Json::nullValue);
|
Json::Value GetPref(Json::Value root, ByteString prop, Json::Value defaultValue = Json::nullValue);
|
||||||
Json::Value SetPrefHelper(Json::Value root, std::string prop, Json::Value value);
|
Json::Value SetPrefHelper(Json::Value root, ByteString prop, Json::Value value);
|
||||||
|
|
||||||
// Save stealing info
|
// Save stealing info
|
||||||
Json::Value authors;
|
Json::Value authors;
|
||||||
@ -107,30 +108,30 @@ public:
|
|||||||
Client();
|
Client();
|
||||||
~Client();
|
~Client();
|
||||||
|
|
||||||
std::vector<std::string> DirectorySearch(std::string directory, std::string search, std::vector<std::string> extensions);
|
std::vector<ByteString> DirectorySearch(ByteString directory, ByteString search, std::vector<ByteString> extensions);
|
||||||
std::vector<std::string> DirectorySearch(std::string directory, std::string search, std::string extension);
|
std::vector<ByteString> DirectorySearch(ByteString directory, ByteString search, ByteString extension);
|
||||||
|
|
||||||
std::string FileOpenDialogue();
|
ByteString FileOpenDialogue();
|
||||||
//std::string FileSaveDialogue();
|
//std::string FileSaveDialogue();
|
||||||
|
|
||||||
bool DoInstallation();
|
bool DoInstallation();
|
||||||
|
|
||||||
std::vector<unsigned char> ReadFile(std::string filename);
|
std::vector<unsigned char> ReadFile(ByteString filename);
|
||||||
|
|
||||||
void AddServerNotification(std::pair<std::string, std::string> notification);
|
void AddServerNotification(std::pair<String, ByteString> notification);
|
||||||
std::vector<std::pair<std::string, std::string> > GetServerNotifications();
|
std::vector<std::pair<String, ByteString> > GetServerNotifications();
|
||||||
|
|
||||||
void SetMessageOfTheDay(std::string message);
|
void SetMessageOfTheDay(String message);
|
||||||
std::string GetMessageOfTheDay();
|
String GetMessageOfTheDay();
|
||||||
|
|
||||||
void Initialise(std::string proxyString);
|
void Initialise(ByteString proxyString);
|
||||||
void SetProxy(std::string proxy);
|
void SetProxy(ByteString proxy);
|
||||||
bool IsFirstRun();
|
bool IsFirstRun();
|
||||||
|
|
||||||
int MakeDirectory(const char * dirname);
|
int MakeDirectory(const char * dirname);
|
||||||
bool WriteFile(std::vector<unsigned char> fileData, std::string filename);
|
bool WriteFile(std::vector<unsigned char> fileData, ByteString filename);
|
||||||
bool WriteFile(std::vector<char> fileData, std::string filename);
|
bool WriteFile(std::vector<char> fileData, ByteString filename);
|
||||||
bool FileExists(std::string filename);
|
bool FileExists(ByteString filename);
|
||||||
|
|
||||||
void AddListener(ClientListener * listener);
|
void AddListener(ClientListener * listener);
|
||||||
void RemoveListener(ClientListener * listener);
|
void RemoveListener(ClientListener * listener);
|
||||||
@ -138,30 +139,30 @@ public:
|
|||||||
RequestStatus ExecVote(int saveID, int direction);
|
RequestStatus ExecVote(int saveID, int direction);
|
||||||
RequestStatus UploadSave(SaveInfo & save);
|
RequestStatus UploadSave(SaveInfo & save);
|
||||||
|
|
||||||
SaveFile * GetStamp(std::string stampID);
|
SaveFile * GetStamp(ByteString stampID);
|
||||||
void DeleteStamp(std::string stampID);
|
void DeleteStamp(ByteString stampID);
|
||||||
std::string AddStamp(GameSave * saveData);
|
ByteString AddStamp(GameSave * saveData);
|
||||||
std::vector<std::string> GetStamps(int start, int count);
|
std::vector<ByteString> GetStamps(int start, int count);
|
||||||
void RescanStamps();
|
void RescanStamps();
|
||||||
int GetStampsCount();
|
int GetStampsCount();
|
||||||
SaveFile * GetFirstStamp();
|
SaveFile * GetFirstStamp();
|
||||||
void MoveStampToFront(std::string stampID);
|
void MoveStampToFront(ByteString stampID);
|
||||||
void updateStamps();
|
void updateStamps();
|
||||||
|
|
||||||
RequestStatus AddComment(int saveID, std::string comment);
|
RequestStatus AddComment(int saveID, String comment);
|
||||||
|
|
||||||
//Retrieves a "UserInfo" object
|
//Retrieves a "UserInfo" object
|
||||||
RequestBroker::Request * GetUserInfoAsync(std::string username);
|
RequestBroker::Request * GetUserInfoAsync(ByteString username);
|
||||||
RequestBroker::Request * SaveUserInfoAsync(UserInfo info);
|
RequestBroker::Request * SaveUserInfoAsync(UserInfo info);
|
||||||
|
|
||||||
RequestBroker::Request * GetSaveDataAsync(int saveID, int saveDate);
|
RequestBroker::Request * GetSaveDataAsync(int saveID, int saveDate);
|
||||||
unsigned char * GetSaveData(int saveID, int saveDate, int & dataLength);
|
unsigned char * GetSaveData(int saveID, int saveDate, int & dataLength);
|
||||||
std::vector<unsigned char> GetSaveData(int saveID, int saveDate);
|
std::vector<unsigned char> GetSaveData(int saveID, int saveDate);
|
||||||
|
|
||||||
LoginStatus Login(std::string username, std::string password, User & user);
|
LoginStatus Login(ByteString username, ByteString password, User & user);
|
||||||
void ClearThumbnailRequests();
|
void ClearThumbnailRequests();
|
||||||
std::vector<SaveInfo*> * SearchSaves(int start, int count, std::string query, std::string sort, std::string category, int & resultCount);
|
std::vector<SaveInfo*> * SearchSaves(int start, int count, String query, ByteString sort, ByteString category, int & resultCount);
|
||||||
std::vector<std::pair<std::string, int> > * GetTags(int start, int count, std::string query, int & resultCount);
|
std::vector<std::pair<ByteString, int> > * GetTags(int start, int count, String query, int & resultCount);
|
||||||
|
|
||||||
RequestBroker::Request * GetCommentsAsync(int saveID, int start, int count);
|
RequestBroker::Request * GetCommentsAsync(int saveID, int start, int count);
|
||||||
|
|
||||||
@ -169,15 +170,15 @@ public:
|
|||||||
RequestBroker::Request * GetSaveAsync(int saveID, int saveDate);
|
RequestBroker::Request * GetSaveAsync(int saveID, int saveDate);
|
||||||
|
|
||||||
RequestStatus DeleteSave(int saveID);
|
RequestStatus DeleteSave(int saveID);
|
||||||
RequestStatus ReportSave(int saveID, std::string message);
|
RequestStatus ReportSave(int saveID, String message);
|
||||||
RequestStatus UnpublishSave(int saveID);
|
RequestStatus UnpublishSave(int saveID);
|
||||||
RequestStatus PublishSave(int saveID);
|
RequestStatus PublishSave(int saveID);
|
||||||
RequestStatus FavouriteSave(int saveID, bool favourite);
|
RequestStatus FavouriteSave(int saveID, bool favourite);
|
||||||
void SetAuthUser(User user);
|
void SetAuthUser(User user);
|
||||||
User GetAuthUser();
|
User GetAuthUser();
|
||||||
std::list<std::string> * RemoveTag(int saveID, std::string tag); //TODO RequestStatus
|
std::list<ByteString> * RemoveTag(int saveID, ByteString tag); //TODO RequestStatus
|
||||||
std::list<std::string> * AddTag(int saveID, std::string tag);
|
std::list<ByteString> * AddTag(int saveID, ByteString tag);
|
||||||
std::string GetLastError() {
|
String GetLastError() {
|
||||||
return lastError;
|
return lastError;
|
||||||
}
|
}
|
||||||
RequestStatus ParseServerReturn(char *result, int status, bool json);
|
RequestStatus ParseServerReturn(char *result, int status, bool json);
|
||||||
@ -188,19 +189,22 @@ public:
|
|||||||
// preferences functions
|
// preferences functions
|
||||||
void WritePrefs();
|
void WritePrefs();
|
||||||
|
|
||||||
std::string GetPrefString(std::string prop, std::string defaultValue);
|
ByteString GetPrefByteString(ByteString prop, ByteString defaultValue);
|
||||||
double GetPrefNumber(std::string prop, double defaultValue);
|
String GetPrefString(ByteString prop, String defaultValue);
|
||||||
int GetPrefInteger(std::string prop, int defaultValue);
|
double GetPrefNumber(ByteString prop, double defaultValue);
|
||||||
unsigned int GetPrefUInteger(std::string prop, unsigned int defaultValue);
|
int GetPrefInteger(ByteString prop, int defaultValue);
|
||||||
bool GetPrefBool(std::string prop, bool defaultValue);
|
unsigned int GetPrefUInteger(ByteString prop, unsigned int defaultValue);
|
||||||
std::vector<std::string> GetPrefStringArray(std::string prop);
|
bool GetPrefBool(ByteString prop, bool defaultValue);
|
||||||
std::vector<double> GetPrefNumberArray(std::string prop);
|
std::vector<ByteString> GetPrefByteStringArray(ByteString prop);
|
||||||
std::vector<int> GetPrefIntegerArray(std::string prop);
|
std::vector<String> GetPrefStringArray(ByteString prop);
|
||||||
std::vector<unsigned int> GetPrefUIntegerArray(std::string prop);
|
std::vector<double> GetPrefNumberArray(ByteString prop);
|
||||||
std::vector<bool> GetPrefBoolArray(std::string prop);
|
std::vector<int> GetPrefIntegerArray(ByteString prop);
|
||||||
|
std::vector<unsigned int> GetPrefUIntegerArray(ByteString prop);
|
||||||
|
std::vector<bool> GetPrefBoolArray(ByteString prop);
|
||||||
|
|
||||||
void SetPref(std::string prop, Json::Value value);
|
void SetPref(ByteString prop, Json::Value value);
|
||||||
void SetPref(std::string property, std::vector<Json::Value> value);
|
void SetPref(ByteString property, std::vector<Json::Value> value);
|
||||||
|
void SetPrefUnicode(ByteString prop, String value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CLIENT_H
|
#endif // CLIENT_H
|
||||||
|
@ -11,7 +11,7 @@ public:
|
|||||||
virtual void NotifyUpdateAvailable(Client * sender) {}
|
virtual void NotifyUpdateAvailable(Client * sender) {}
|
||||||
virtual void NotifyAuthUserChanged(Client * sender) {}
|
virtual void NotifyAuthUserChanged(Client * sender) {}
|
||||||
virtual void NotifyMessageOfTheDay(Client * sender) {}
|
virtual void NotifyMessageOfTheDay(Client * sender) {}
|
||||||
virtual void NotifyNewNotification(Client * sender, std::pair<std::string, std::string> notification) {}
|
virtual void NotifyNewNotification(Client * sender, std::pair<String, ByteString> notification) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "DownloadManager.h"
|
#include "DownloadManager.h"
|
||||||
#include "HTTP.h"
|
#include "HTTP.h"
|
||||||
|
|
||||||
Download::Download(std::string uri_, bool keepAlive):
|
Download::Download(ByteString uri_, bool keepAlive):
|
||||||
http(NULL),
|
http(NULL),
|
||||||
keepAlive(keepAlive),
|
keepAlive(keepAlive),
|
||||||
downloadData(NULL),
|
downloadData(NULL),
|
||||||
@ -17,7 +17,7 @@ Download::Download(std::string uri_, bool keepAlive):
|
|||||||
downloadCanceled(false),
|
downloadCanceled(false),
|
||||||
downloadStarted(false)
|
downloadStarted(false)
|
||||||
{
|
{
|
||||||
uri = std::string(uri_);
|
uri = ByteString(uri_);
|
||||||
DownloadManager::Ref().AddDownload(this);
|
DownloadManager::Ref().AddDownload(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,20 +31,20 @@ Download::~Download()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add post data to a request
|
// add post data to a request
|
||||||
void Download::AddPostData(std::map<std::string, std::string> data)
|
void Download::AddPostData(std::map<ByteString, ByteString> data)
|
||||||
{
|
{
|
||||||
postDataBoundary = FindBoundary(data, "");
|
postDataBoundary = FindBoundary(data, "");
|
||||||
postData = GetMultipartMessage(data, postDataBoundary);
|
postData = GetMultipartMessage(data, postDataBoundary);
|
||||||
}
|
}
|
||||||
void Download::AddPostData(std::pair<std::string, std::string> data)
|
void Download::AddPostData(std::pair<ByteString, ByteString> data)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::string> postData;
|
std::map<ByteString, ByteString> postData;
|
||||||
postData.insert(data);
|
postData.insert(data);
|
||||||
AddPostData(postData);
|
AddPostData(postData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add userID and sessionID headers to the download. Must be done after download starts for some reason
|
// add userID and sessionID headers to the download. Must be done after download starts for some reason
|
||||||
void Download::AuthHeaders(std::string ID, std::string session)
|
void Download::AuthHeaders(ByteString ID, ByteString session)
|
||||||
{
|
{
|
||||||
if (ID != "0")
|
if (ID != "0")
|
||||||
userID = ID;
|
userID = ID;
|
||||||
@ -68,13 +68,13 @@ void Download::Start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for persistent connections (keepAlive = true), reuse the open connection to make another request
|
// for persistent connections (keepAlive = true), reuse the open connection to make another request
|
||||||
bool Download::Reuse(std::string newuri)
|
bool Download::Reuse(ByteString newuri)
|
||||||
{
|
{
|
||||||
if (!keepAlive || !CheckDone() || CheckCanceled())
|
if (!keepAlive || !CheckDone() || CheckCanceled())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uri = std::string(newuri);
|
uri = newuri;
|
||||||
DownloadManager::Ref().Lock();
|
DownloadManager::Ref().Lock();
|
||||||
downloadFinished = false;
|
downloadFinished = false;
|
||||||
DownloadManager::Ref().Unlock();
|
DownloadManager::Ref().Unlock();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#ifndef DOWNLOAD_H
|
#ifndef DOWNLOAD_H
|
||||||
#define DOWNLOAD_H
|
#define DOWNLOAD_H
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
|
|
||||||
class DownloadManager;
|
class DownloadManager;
|
||||||
class Download
|
class Download
|
||||||
{
|
{
|
||||||
std::string uri;
|
ByteString uri;
|
||||||
void *http;
|
void *http;
|
||||||
bool keepAlive;
|
bool keepAlive;
|
||||||
|
|
||||||
@ -14,25 +14,25 @@ class Download
|
|||||||
int downloadSize;
|
int downloadSize;
|
||||||
int downloadStatus;
|
int downloadStatus;
|
||||||
|
|
||||||
std::string postData;
|
ByteString postData;
|
||||||
std::string postDataBoundary;
|
ByteString postDataBoundary;
|
||||||
|
|
||||||
std::string userID;
|
ByteString userID;
|
||||||
std::string userSession;
|
ByteString userSession;
|
||||||
|
|
||||||
volatile bool downloadFinished;
|
volatile bool downloadFinished;
|
||||||
volatile bool downloadCanceled;
|
volatile bool downloadCanceled;
|
||||||
volatile bool downloadStarted;
|
volatile bool downloadStarted;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Download(std::string uri, bool keepAlive = false);
|
Download(ByteString uri, bool keepAlive = false);
|
||||||
~Download();
|
~Download();
|
||||||
|
|
||||||
void AddPostData(std::map<std::string, std::string> data);
|
void AddPostData(std::map<ByteString, ByteString> data);
|
||||||
void AddPostData(std::pair<std::string, std::string> data);
|
void AddPostData(std::pair<ByteString, ByteString> data);
|
||||||
void AuthHeaders(std::string ID, std::string session);
|
void AuthHeaders(ByteString ID, ByteString session);
|
||||||
void Start();
|
void Start();
|
||||||
bool Reuse(std::string newuri);
|
bool Reuse(ByteString newuri);
|
||||||
char* Finish(int *length, int *status);
|
char* Finish(int *length, int *status);
|
||||||
void Cancel();
|
void Cancel();
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "common/tpt-minmax.h"
|
#include "common/tpt-minmax.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -633,7 +632,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
|||||||
throw ParseException(ParseException::Corrupt, "Unable to decompress (ret " + format::NumberToString<int>(bz2ret) + ")");
|
throw ParseException(ParseException::Corrupt, "Unable to decompress (ret " + format::NumberToString<int>(bz2ret) + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
set_bson_err_handler([](const char* err) { throw ParseException(ParseException::Corrupt, "BSON error when parsing save: " + std::string(err)); });
|
set_bson_err_handler([](const char* err) { throw ParseException(ParseException::Corrupt, "BSON error when parsing save: " + ByteString(err).FromUtf8()); });
|
||||||
bson_init_data_size(&b, (char*)bsonData, bsonDataLen);
|
bson_init_data_size(&b, (char*)bsonData, bsonDataLen);
|
||||||
bson_iterator_init(&iter, &b);
|
bson_iterator_init(&iter, &b);
|
||||||
|
|
||||||
@ -679,7 +678,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
|||||||
{
|
{
|
||||||
if (!strcmp(bson_iterator_key(&signiter), "text") && bson_iterator_type(&signiter) == BSON_STRING)
|
if (!strcmp(bson_iterator_key(&signiter), "text") && bson_iterator_type(&signiter) == BSON_STRING)
|
||||||
{
|
{
|
||||||
tempSign.text = format::CleanString(bson_iterator_string(&signiter), true, true, true).substr(0, 45);
|
tempSign.text = format::CleanString(ByteString(bson_iterator_string(&signiter)).FromUtf8(), true, true, true).substr(0, 45);
|
||||||
}
|
}
|
||||||
else if (!strcmp(bson_iterator_key(&signiter), "justification") && bson_iterator_type(&signiter) == BSON_INT)
|
else if (!strcmp(bson_iterator_key(&signiter), "justification") && bson_iterator_type(&signiter) == BSON_INT)
|
||||||
{
|
{
|
||||||
@ -764,7 +763,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
|||||||
{
|
{
|
||||||
if (bson_iterator_type(&subiter) == BSON_INT)
|
if (bson_iterator_type(&subiter) == BSON_INT)
|
||||||
{
|
{
|
||||||
std::string id = std::string(bson_iterator_key(&subiter));
|
ByteString id = bson_iterator_key(&subiter);
|
||||||
int num = bson_iterator_int(&subiter);
|
int num = bson_iterator_int(&subiter);
|
||||||
palette.push_back(PaletteItem(id, num));
|
palette.push_back(PaletteItem(id, num));
|
||||||
}
|
}
|
||||||
@ -806,7 +805,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
|||||||
if (major > SAVE_VERSION || (major == SAVE_VERSION && minor > MINOR_VERSION))
|
if (major > SAVE_VERSION || (major == SAVE_VERSION && minor > MINOR_VERSION))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
std::stringstream errorMessage;
|
String::Stream errorMessage;
|
||||||
#ifdef RENDERER
|
#ifdef RENDERER
|
||||||
errorMessage << "Save from a newer version: Requires render version " << renderMajor << "." << renderMinor;
|
errorMessage << "Save from a newer version: Requires render version " << renderMajor << "." << renderMinor;
|
||||||
#else
|
#else
|
||||||
@ -1333,18 +1332,8 @@ void GameSave::readPSv(char * saveDataChar, int dataLength)
|
|||||||
sign tempSign("", 0, 0, sign::Left);
|
sign tempSign("", 0, 0, sign::Left);
|
||||||
|
|
||||||
//Gol data used to read older saves
|
//Gol data used to read older saves
|
||||||
int goltype[NGOL];
|
std::vector<int> goltype = LoadGOLTypes();
|
||||||
int grule[NGOL+1][10];
|
std::vector<std::array<int, 10> > grule = LoadGOLRules();
|
||||||
|
|
||||||
int golRulesCount;
|
|
||||||
int * golRulesT = LoadGOLRules(golRulesCount);
|
|
||||||
memcpy(grule, golRulesT, sizeof(int) * (golRulesCount*10));
|
|
||||||
free(golRulesT);
|
|
||||||
|
|
||||||
int golTypesCount;
|
|
||||||
int * golTypesT = LoadGOLTypes(golTypesCount);
|
|
||||||
memcpy(goltype, golTypesT, sizeof(int) * (golTypesCount));
|
|
||||||
free(golTypesT);
|
|
||||||
|
|
||||||
std::vector<Element> elements = GetElements();
|
std::vector<Element> elements = GetElements();
|
||||||
|
|
||||||
@ -1419,7 +1408,7 @@ void GameSave::readPSv(char * saveDataChar, int dataLength)
|
|||||||
int bzStatus = 0;
|
int bzStatus = 0;
|
||||||
if ((bzStatus = BZ2_bzBuffToBuffDecompress((char *)data, (unsigned *)&size, (char *)(saveData+12), dataLength-12, 0, 0)))
|
if ((bzStatus = BZ2_bzBuffToBuffDecompress((char *)data, (unsigned *)&size, (char *)(saveData+12), dataLength-12, 0, 0)))
|
||||||
{
|
{
|
||||||
std::stringstream bzStatusStr;
|
String::Stream bzStatusStr;
|
||||||
bzStatusStr << bzStatus;
|
bzStatusStr << bzStatus;
|
||||||
throw ParseException(ParseException::Corrupt, "Cannot decompress: " + bzStatusStr.str());
|
throw ParseException(ParseException::Corrupt, "Cannot decompress: " + bzStatusStr.str());
|
||||||
}
|
}
|
||||||
@ -2399,7 +2388,7 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
|
|||||||
// Use unique_ptr with a custom deleter to ensure that bson_destroy is called even when an exception is thrown
|
// Use unique_ptr with a custom deleter to ensure that bson_destroy is called even when an exception is thrown
|
||||||
std::unique_ptr<bson, decltype(bson_deleter)> b_ptr(&b, bson_deleter);
|
std::unique_ptr<bson, decltype(bson_deleter)> b_ptr(&b, bson_deleter);
|
||||||
|
|
||||||
set_bson_err_handler([](const char* err) { throw BuildException("BSON error when parsing save: " + std::string(err)); });
|
set_bson_err_handler([](const char* err) { throw BuildException("BSON error when parsing save: " + ByteString(err).FromUtf8()); });
|
||||||
bson_init(&b);
|
bson_init(&b);
|
||||||
bson_append_start_object(&b, "origin");
|
bson_append_start_object(&b, "origin");
|
||||||
bson_append_int(&b, "majorVersion", SAVE_VERSION);
|
bson_append_int(&b, "majorVersion", SAVE_VERSION);
|
||||||
@ -2504,7 +2493,7 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
|
|||||||
if(signs[i].text.length() && signs[i].x>=0 && signs[i].x<=fullW && signs[i].y>=0 && signs[i].y<=fullH)
|
if(signs[i].text.length() && signs[i].x>=0 && signs[i].x<=fullW && signs[i].y>=0 && signs[i].y<=fullH)
|
||||||
{
|
{
|
||||||
bson_append_start_object(&b, "sign");
|
bson_append_start_object(&b, "sign");
|
||||||
bson_append_string(&b, "text", signs[i].text.c_str());
|
bson_append_string(&b, "text", signs[i].text.ToUtf8().c_str());
|
||||||
bson_append_int(&b, "justification", signs[i].ju);
|
bson_append_int(&b, "justification", signs[i].ju);
|
||||||
bson_append_int(&b, "x", signs[i].x);
|
bson_append_int(&b, "x", signs[i].x);
|
||||||
bson_append_int(&b, "y", signs[i].y);
|
bson_append_int(&b, "y", signs[i].y);
|
||||||
@ -2563,7 +2552,7 @@ void GameSave::ConvertBsonToJson(bson_iterator *iter, Json::Value *j, int depth)
|
|||||||
bson_iterator_subiterator(iter, &subiter);
|
bson_iterator_subiterator(iter, &subiter);
|
||||||
while (bson_iterator_next(&subiter))
|
while (bson_iterator_next(&subiter))
|
||||||
{
|
{
|
||||||
std::string key = bson_iterator_key(&subiter);
|
ByteString key = bson_iterator_key(&subiter);
|
||||||
if (bson_iterator_type(&subiter) == BSON_STRING)
|
if (bson_iterator_type(&subiter) == BSON_STRING)
|
||||||
(*j)[key] = bson_iterator_string(&subiter);
|
(*j)[key] = bson_iterator_string(&subiter);
|
||||||
else if (bson_iterator_type(&subiter) == BSON_BOOL)
|
else if (bson_iterator_type(&subiter) == BSON_BOOL)
|
||||||
@ -2604,7 +2593,7 @@ std::set<int> GetNestedSaveIDs(Json::Value j)
|
|||||||
std::set<int> saveIDs = std::set<int>();
|
std::set<int> saveIDs = std::set<int>();
|
||||||
for (Json::Value::Members::iterator iter = members.begin(), end = members.end(); iter != end; ++iter)
|
for (Json::Value::Members::iterator iter = members.begin(), end = members.end(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
std::string member = *iter;
|
ByteString member = *iter;
|
||||||
if (member == "id" && j[member].isInt())
|
if (member == "id" && j[member].isInt())
|
||||||
saveIDs.insert(j[member].asInt());
|
saveIDs.insert(j[member].asInt());
|
||||||
else if (j[member].isArray())
|
else if (j[member].isArray())
|
||||||
@ -2633,7 +2622,7 @@ void GameSave::ConvertJsonToBson(bson *b, Json::Value j, int depth)
|
|||||||
Json::Value::Members members = j.getMemberNames();
|
Json::Value::Members members = j.getMemberNames();
|
||||||
for (Json::Value::Members::iterator iter = members.begin(), end = members.end(); iter != end; ++iter)
|
for (Json::Value::Members::iterator iter = members.begin(), end = members.end(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
std::string member = *iter;
|
ByteString member = *iter;
|
||||||
if (j[member].isString())
|
if (j[member].isString())
|
||||||
bson_append_string(b, member.c_str(), j[member].asCString());
|
bson_append_string(b, member.c_str(), j[member].asCString());
|
||||||
else if (j[member].isBool())
|
else if (j[member].isBool())
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define The_Powder_Toy_GameSave_h
|
#define The_Powder_Toy_GameSave_h
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Misc.h"
|
#include "Misc.h"
|
||||||
|
|
||||||
@ -15,24 +15,24 @@
|
|||||||
|
|
||||||
struct ParseException: public std::exception {
|
struct ParseException: public std::exception {
|
||||||
enum ParseResult { OK = 0, Corrupt, WrongVersion, InvalidDimensions, InternalError, MissingElement };
|
enum ParseResult { OK = 0, Corrupt, WrongVersion, InvalidDimensions, InternalError, MissingElement };
|
||||||
std::string message;
|
String message;
|
||||||
ParseResult result;
|
ParseResult result;
|
||||||
public:
|
public:
|
||||||
ParseException(ParseResult result, std::string message_): message(message_), result(result) {}
|
ParseException(ParseResult result, String message_): message(message_), result(result) {}
|
||||||
const char * what() const throw()
|
const char * what() const throw()
|
||||||
{
|
{
|
||||||
return message.c_str();
|
return message.ToUtf8().c_str();
|
||||||
}
|
}
|
||||||
~ParseException() throw() {}
|
~ParseException() throw() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BuildException: public std::exception {
|
struct BuildException: public std::exception {
|
||||||
std::string message;
|
String message;
|
||||||
public:
|
public:
|
||||||
BuildException(std::string message_): message(message_) {}
|
BuildException(String message_): message(message_) {}
|
||||||
const char * what() const throw()
|
const char * what() const throw()
|
||||||
{
|
{
|
||||||
return message.c_str();
|
return message.ToUtf8().c_str();
|
||||||
}
|
}
|
||||||
~BuildException() throw() {}
|
~BuildException() throw() {}
|
||||||
};
|
};
|
||||||
@ -104,7 +104,7 @@ public:
|
|||||||
StkmData stkm;
|
StkmData stkm;
|
||||||
|
|
||||||
//Element palette
|
//Element palette
|
||||||
typedef std::pair<std::string, int> PaletteItem;
|
typedef std::pair<ByteString, int> PaletteItem;
|
||||||
std::vector<PaletteItem> palette;
|
std::vector<PaletteItem> palette;
|
||||||
|
|
||||||
// author information
|
// author information
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include <sstream>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -193,11 +192,11 @@ void http_init(char *proxy)
|
|||||||
free(host);
|
free(host);
|
||||||
free(port);
|
free(port);
|
||||||
}
|
}
|
||||||
std::stringstream userAgentBuilder;
|
ByteString::Stream userAgentBuilder;
|
||||||
userAgentBuilder << "PowderToy/" << SAVE_VERSION << "." << MINOR_VERSION << " ";
|
userAgentBuilder << "PowderToy/" << SAVE_VERSION << "." << MINOR_VERSION << " ";
|
||||||
userAgentBuilder << "(" << IDENT_PLATFORM << "; " << IDENT_BUILD << "; M" << MOD_ID << ") ";
|
userAgentBuilder << "(" << IDENT_PLATFORM << "; " << IDENT_BUILD << "; M" << MOD_ID << ") ";
|
||||||
userAgentBuilder << "TPTPP/" << SAVE_VERSION << "." << MINOR_VERSION << "." << BUILD_NUM << IDENT_RELTYPE << "." << SNAPSHOT_ID;
|
userAgentBuilder << "TPTPP/" << SAVE_VERSION << "." << MINOR_VERSION << "." << BUILD_NUM << IDENT_RELTYPE << "." << SNAPSHOT_ID;
|
||||||
std::string newUserAgent = userAgentBuilder.str();
|
ByteString newUserAgent = userAgentBuilder.str();
|
||||||
userAgent = new char[newUserAgent.length()+1];
|
userAgent = new char[newUserAgent.length()+1];
|
||||||
std::copy(newUserAgent.begin(), newUserAgent.end(), userAgent);
|
std::copy(newUserAgent.begin(), newUserAgent.end(), userAgent);
|
||||||
userAgent[newUserAgent.length()] = 0;
|
userAgent[newUserAgent.length()] = 0;
|
||||||
@ -938,13 +937,13 @@ const char *http_ret_text(int ret)
|
|||||||
// Find the boundary used in the multipart POST request
|
// Find the boundary used in the multipart POST request
|
||||||
// the boundary is a string that never appears in any of the parts, ex. 'A92'
|
// the boundary is a string that never appears in any of the parts, ex. 'A92'
|
||||||
// keeps looking recursively until it finds one
|
// keeps looking recursively until it finds one
|
||||||
std::string FindBoundary(std::map<std::string, std::string> parts, std::string boundary)
|
ByteString FindBoundary(std::map<ByteString, ByteString> parts, ByteString boundary)
|
||||||
{
|
{
|
||||||
// we only look for a-zA-Z0-9 chars
|
// we only look for a-zA-Z0-9 chars
|
||||||
unsigned int map[62];
|
unsigned int map[62];
|
||||||
size_t blen = boundary.length();
|
size_t blen = boundary.length();
|
||||||
std::fill(&map[0], &map[62], 0);
|
std::fill(&map[0], &map[62], 0);
|
||||||
for (std::map<std::string, std::string>::iterator iter = parts.begin(); iter != parts.end(); iter++)
|
for (std::map<ByteString, ByteString>::iterator iter = parts.begin(); iter != parts.end(); iter++)
|
||||||
{
|
{
|
||||||
// loop through every character in each part and search for the substring, adding 1 to map for every character found (character after the substring)
|
// loop through every character in each part and search for the substring, adding 1 to map for every character found (character after the substring)
|
||||||
for (ssize_t j = 0; j < (ssize_t)((*iter).second.length()-blen); j++)
|
for (ssize_t j = 0; j < (ssize_t)((*iter).second.length()-blen); j++)
|
||||||
@ -986,15 +985,15 @@ std::string FindBoundary(std::map<std::string, std::string> parts, std::string b
|
|||||||
// Generates a MIME multipart message to be used in POST requests
|
// Generates a MIME multipart message to be used in POST requests
|
||||||
// see https://en.wikipedia.org/wiki/MIME#Multipart_messages
|
// see https://en.wikipedia.org/wiki/MIME#Multipart_messages
|
||||||
// this function used in Download class, and eventually all http requests
|
// this function used in Download class, and eventually all http requests
|
||||||
std::string GetMultipartMessage(std::map<std::string, std::string> parts, std::string boundary)
|
ByteString GetMultipartMessage(std::map<ByteString, ByteString> parts, ByteString boundary)
|
||||||
{
|
{
|
||||||
std::stringstream data;
|
ByteString::Stream data;
|
||||||
|
|
||||||
// loop through each part, adding it
|
// loop through each part, adding it
|
||||||
for (std::map<std::string, std::string>::iterator iter = parts.begin(); iter != parts.end(); iter++)
|
for (std::map<ByteString, ByteString>::iterator iter = parts.begin(); iter != parts.end(); iter++)
|
||||||
{
|
{
|
||||||
std::string name = (*iter).first;
|
ByteString name = (*iter).first;
|
||||||
std::string value = (*iter).second;
|
ByteString value = (*iter).second;
|
||||||
|
|
||||||
data << "--" << boundary << "\r\n";
|
data << "--" << boundary << "\r\n";
|
||||||
data << "Content-transfer-encoding: binary" << "\r\n";
|
data << "Content-transfer-encoding: binary" << "\r\n";
|
||||||
@ -1020,9 +1019,9 @@ std::string GetMultipartMessage(std::map<std::string, std::string> parts, std::s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add the header needed to make POSTS work
|
// add the header needed to make POSTS work
|
||||||
void http_add_multipart_header(void *ctx, std::string boundary)
|
void http_add_multipart_header(void *ctx, ByteString boundary)
|
||||||
{
|
{
|
||||||
std::string header = "multipart/form-data; boundary=" + boundary;
|
ByteString header = "multipart/form-data; boundary=" + boundary;
|
||||||
http_async_add_header(ctx, "Content-type", header.c_str());
|
http_async_add_header(ctx, "Content-type", header.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define HTTP_H
|
#define HTTP_H
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
|
|
||||||
static const char hexChars[] = "0123456789abcdef";
|
static const char hexChars[] = "0123456789abcdef";
|
||||||
static const long http_timeout = 15;
|
static const long http_timeout = 15;
|
||||||
@ -43,9 +43,9 @@ char *http_async_req_stop(void *ctx, int *ret, int *len);
|
|||||||
void http_async_req_close(void *ctx);
|
void http_async_req_close(void *ctx);
|
||||||
void http_force_close(void *ctx);
|
void http_force_close(void *ctx);
|
||||||
|
|
||||||
std::string FindBoundary(std::map<std::string, std::string>, std::string boundary);
|
ByteString FindBoundary(std::map<ByteString, ByteString>, ByteString boundary);
|
||||||
std::string GetMultipartMessage(std::map<std::string, std::string>, std::string boundary);
|
ByteString GetMultipartMessage(std::map<ByteString, ByteString>, ByteString boundary);
|
||||||
void http_add_multipart_header(void *ctx, std::string boundary);
|
void http_add_multipart_header(void *ctx, ByteString boundary);
|
||||||
char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, size_t *plens, const char *user, const char *pass, const char * session_id, int *ret, int *len);
|
char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, size_t *plens, const char *user, const char *pass, const char * session_id, int *ret, int *len);
|
||||||
void *http_multipart_post_async(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id);
|
void *http_multipart_post_async(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id);
|
||||||
|
|
||||||
|
@ -26,11 +26,11 @@ void SaveFile::SetThumbnail(Thumbnail * thumb)
|
|||||||
thumbnail = thumb;
|
thumbnail = thumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveFile::SaveFile(std::string filename):
|
SaveFile::SaveFile(ByteString filename):
|
||||||
thumbnail(NULL),
|
thumbnail(NULL),
|
||||||
gameSave(NULL),
|
gameSave(NULL),
|
||||||
filename(filename),
|
filename(filename),
|
||||||
displayName(filename),
|
displayName(filename.FromUtf8()),
|
||||||
loadingError("")
|
loadingError("")
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -46,32 +46,32 @@ void SaveFile::SetGameSave(GameSave * save)
|
|||||||
gameSave = save;
|
gameSave = save;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SaveFile::GetName()
|
ByteString SaveFile::GetName()
|
||||||
{
|
{
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveFile::SetFileName(std::string fileName)
|
void SaveFile::SetFileName(ByteString fileName)
|
||||||
{
|
{
|
||||||
this->filename = fileName;
|
this->filename = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SaveFile::GetDisplayName()
|
String SaveFile::GetDisplayName()
|
||||||
{
|
{
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveFile::SetDisplayName(std::string displayName)
|
void SaveFile::SetDisplayName(String displayName)
|
||||||
{
|
{
|
||||||
this->displayName = displayName;
|
this->displayName = displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SaveFile::GetError()
|
String SaveFile::GetError()
|
||||||
{
|
{
|
||||||
return loadingError;
|
return loadingError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveFile::SetLoadingError(std::string error)
|
void SaveFile::SetLoadingError(String error)
|
||||||
{
|
{
|
||||||
loadingError = error;
|
loadingError = error;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef SAVEFILE_H_
|
#ifndef SAVEFILE_H_
|
||||||
#define SAVEFILE_H_
|
#define SAVEFILE_H_
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
|
|
||||||
class GameSave;
|
class GameSave;
|
||||||
class Thumbnail;
|
class Thumbnail;
|
||||||
@ -9,26 +9,26 @@ class Thumbnail;
|
|||||||
class SaveFile {
|
class SaveFile {
|
||||||
public:
|
public:
|
||||||
SaveFile(SaveFile & save);
|
SaveFile(SaveFile & save);
|
||||||
SaveFile(std::string filename);
|
SaveFile(ByteString filename);
|
||||||
|
|
||||||
Thumbnail * GetThumbnail();
|
Thumbnail * GetThumbnail();
|
||||||
GameSave * GetGameSave();
|
GameSave * GetGameSave();
|
||||||
void SetThumbnail(Thumbnail * thumb);
|
void SetThumbnail(Thumbnail * thumb);
|
||||||
void SetGameSave(GameSave * save);
|
void SetGameSave(GameSave * save);
|
||||||
std::string GetDisplayName();
|
String GetDisplayName();
|
||||||
void SetDisplayName(std::string displayName);
|
void SetDisplayName(String displayName);
|
||||||
std::string GetName();
|
ByteString GetName();
|
||||||
void SetFileName(std::string fileName);
|
void SetFileName(ByteString fileName);
|
||||||
std::string GetError();
|
String GetError();
|
||||||
void SetLoadingError(std::string error);
|
void SetLoadingError(String error);
|
||||||
|
|
||||||
virtual ~SaveFile();
|
virtual ~SaveFile();
|
||||||
private:
|
private:
|
||||||
Thumbnail * thumbnail;
|
Thumbnail * thumbnail;
|
||||||
GameSave * gameSave;
|
GameSave * gameSave;
|
||||||
std::string filename;
|
ByteString filename;
|
||||||
std::string displayName;
|
String displayName;
|
||||||
std::string loadingError;
|
String loadingError;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SAVEFILE_H_ */
|
#endif /* SAVEFILE_H_ */
|
||||||
|
@ -19,14 +19,14 @@ SaveInfo::SaveInfo(SaveInfo & save):
|
|||||||
Published(save.Published),
|
Published(save.Published),
|
||||||
gameSave(NULL)
|
gameSave(NULL)
|
||||||
{
|
{
|
||||||
std::list<std::string> tagsSorted = save.tags;
|
std::list<ByteString> tagsSorted = save.tags;
|
||||||
tagsSorted.sort();
|
tagsSorted.sort();
|
||||||
tags = tagsSorted;
|
tags = tagsSorted;
|
||||||
if (save.gameSave)
|
if (save.gameSave)
|
||||||
gameSave = new GameSave(*save.gameSave);
|
gameSave = new GameSave(*save.gameSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, std::string _userName, std::string _name):
|
SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, ByteString _userName, String _name):
|
||||||
id(_id),
|
id(_id),
|
||||||
createdDate(_createdDate),
|
createdDate(_createdDate),
|
||||||
updatedDate(_updatedDate),
|
updatedDate(_updatedDate),
|
||||||
@ -47,7 +47,7 @@ SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, in
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::list<std::string> tags_):
|
SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, ByteString _userName, String _name, String description_, bool published_, std::list<ByteString> tags_):
|
||||||
id(_id),
|
id(_id),
|
||||||
createdDate(_createdDate),
|
createdDate(_createdDate),
|
||||||
updatedDate(_updatedDate),
|
updatedDate(_updatedDate),
|
||||||
@ -65,7 +65,7 @@ SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, in
|
|||||||
tags(),
|
tags(),
|
||||||
gameSave(NULL)
|
gameSave(NULL)
|
||||||
{
|
{
|
||||||
std::list<std::string> tagsSorted = tags_;
|
std::list<ByteString> tagsSorted = tags_;
|
||||||
tagsSorted.sort();
|
tagsSorted.sort();
|
||||||
tags=tagsSorted;
|
tags=tagsSorted;
|
||||||
}
|
}
|
||||||
@ -78,20 +78,20 @@ SaveInfo::~SaveInfo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveInfo::SetName(std::string name)
|
void SaveInfo::SetName(String name)
|
||||||
{
|
{
|
||||||
this->name = name;
|
this->name = name;
|
||||||
}
|
}
|
||||||
std::string SaveInfo::GetName()
|
String SaveInfo::GetName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveInfo::SetDescription(std::string description)
|
void SaveInfo::SetDescription(String description)
|
||||||
{
|
{
|
||||||
Description = description;
|
Description = description;
|
||||||
}
|
}
|
||||||
std::string SaveInfo::GetDescription()
|
String SaveInfo::GetDescription()
|
||||||
{
|
{
|
||||||
return Description;
|
return Description;
|
||||||
}
|
}
|
||||||
@ -114,12 +114,12 @@ int SaveInfo::GetVote()
|
|||||||
return vote;
|
return vote;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveInfo::SetUserName(std::string userName)
|
void SaveInfo::SetUserName(ByteString userName)
|
||||||
{
|
{
|
||||||
this->userName = userName;
|
this->userName = userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SaveInfo::GetUserName()
|
ByteString SaveInfo::GetUserName()
|
||||||
{
|
{
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
@ -160,14 +160,14 @@ int SaveInfo::GetVersion()
|
|||||||
return Version;
|
return Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveInfo::SetTags(std::list<std::string> tags)
|
void SaveInfo::SetTags(std::list<ByteString> tags)
|
||||||
{
|
{
|
||||||
std::list<std::string> tagsSorted = tags;
|
std::list<ByteString> tagsSorted = tags;
|
||||||
tagsSorted.sort();
|
tagsSorted.sort();
|
||||||
this->tags=tagsSorted;
|
this->tags=tagsSorted;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<std::string> SaveInfo::GetTags()
|
std::list<ByteString> SaveInfo::GetTags()
|
||||||
{
|
{
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -23,34 +23,34 @@ public:
|
|||||||
int Views;
|
int Views;
|
||||||
int Version;
|
int Version;
|
||||||
|
|
||||||
std::string userName;
|
ByteString userName;
|
||||||
|
|
||||||
std::string name;
|
String name;
|
||||||
std::string Description;
|
String Description;
|
||||||
bool Published;
|
bool Published;
|
||||||
|
|
||||||
std::list<std::string> tags;
|
std::list<ByteString> tags;
|
||||||
GameSave * gameSave;
|
GameSave * gameSave;
|
||||||
|
|
||||||
SaveInfo(SaveInfo & save);
|
SaveInfo(SaveInfo & save);
|
||||||
|
|
||||||
SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, std::string _userName, std::string _name);
|
SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, ByteString _userName, String _name);
|
||||||
|
|
||||||
SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::list<std::string> tags);
|
SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, ByteString _userName, String _name, String description_, bool published_, std::list<ByteString> tags);
|
||||||
|
|
||||||
~SaveInfo();
|
~SaveInfo();
|
||||||
|
|
||||||
void SetName(std::string name);
|
void SetName(String name);
|
||||||
std::string GetName();
|
String GetName();
|
||||||
|
|
||||||
void SetDescription(std::string description);
|
void SetDescription(String description);
|
||||||
std::string GetDescription();
|
String GetDescription();
|
||||||
|
|
||||||
void SetPublished(bool published);
|
void SetPublished(bool published);
|
||||||
bool GetPublished();
|
bool GetPublished();
|
||||||
|
|
||||||
void SetUserName(std::string userName);
|
void SetUserName(ByteString userName);
|
||||||
std::string GetUserName();
|
ByteString GetUserName();
|
||||||
|
|
||||||
void SetID(int id);
|
void SetID(int id);
|
||||||
int GetID();
|
int GetID();
|
||||||
@ -67,8 +67,8 @@ public:
|
|||||||
void SetVersion(int version);
|
void SetVersion(int version);
|
||||||
int GetVersion();
|
int GetVersion();
|
||||||
|
|
||||||
void SetTags(std::list<std::string> tags);
|
void SetTags(std::list<ByteString> tags);
|
||||||
std::list<std::string> GetTags();
|
std::list<ByteString> GetTags();
|
||||||
|
|
||||||
GameSave * GetGameSave();
|
GameSave * GetGameSave();
|
||||||
void SetGameSave(GameSave * gameSave);
|
void SetGameSave(GameSave * gameSave);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef USER_H_
|
#ifndef USER_H_
|
||||||
#define USER_H_
|
#define USER_H_
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
|
|
||||||
|
|
||||||
class User
|
class User
|
||||||
@ -12,11 +12,11 @@ public:
|
|||||||
ElevationAdmin, ElevationModerator, ElevationNone
|
ElevationAdmin, ElevationModerator, ElevationNone
|
||||||
};
|
};
|
||||||
int UserID;
|
int UserID;
|
||||||
std::string Username;
|
ByteString Username;
|
||||||
std::string SessionID;
|
ByteString SessionID;
|
||||||
std::string SessionKey;
|
ByteString SessionKey;
|
||||||
Elevation UserElevation;
|
Elevation UserElevation;
|
||||||
User(int id, std::string username):
|
User(int id, ByteString username):
|
||||||
UserID(id),
|
UserID(id),
|
||||||
Username(username),
|
Username(username),
|
||||||
SessionID(""),
|
SessionID(""),
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
#ifndef USERINFO_H_
|
#ifndef USERINFO_H_
|
||||||
#define USERINFO_H_
|
#define USERINFO_H_
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
|
|
||||||
class UserInfo
|
class UserInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int UserID;
|
int UserID;
|
||||||
int age;
|
int age;
|
||||||
std::string username;
|
ByteString username;
|
||||||
std::string biography;
|
String biography;
|
||||||
std::string location;
|
String location;
|
||||||
std::string website;
|
ByteString website;
|
||||||
|
|
||||||
int saveCount;
|
int saveCount;
|
||||||
float averageScore;
|
float averageScore;
|
||||||
@ -21,7 +21,7 @@ public:
|
|||||||
int topicReplies;
|
int topicReplies;
|
||||||
int reputation;
|
int reputation;
|
||||||
|
|
||||||
UserInfo(int id, int age, std::string username, std::string biography, std::string location, std::string website, int saveCount, float averageScore, int highestScore, int topicCount, int topicReplies, int reputation):
|
UserInfo(int id, int age, ByteString username, String biography, String location, ByteString website, int saveCount, float averageScore, int highestScore, int topicCount, int topicReplies, int reputation):
|
||||||
UserID(id),
|
UserID(id),
|
||||||
age(age),
|
age(age),
|
||||||
username(username),
|
username(username),
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "client/HTTP.h"
|
#include "client/HTTP.h"
|
||||||
#include "APIResultParser.h"
|
#include "APIResultParser.h"
|
||||||
|
|
||||||
APIRequest::APIRequest(std::string url, APIResultParser * parser, ListenerHandle listener, int identifier):
|
APIRequest::APIRequest(ByteString url, APIResultParser * parser, ListenerHandle listener, int identifier):
|
||||||
RequestBroker::Request(API, listener, identifier)
|
RequestBroker::Request(API, listener, identifier)
|
||||||
{
|
{
|
||||||
Post = false;
|
Post = false;
|
||||||
@ -18,7 +18,7 @@ APIRequest::APIRequest(std::string url, APIResultParser * parser, ListenerHandle
|
|||||||
URL = url;
|
URL = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
APIRequest::APIRequest(std::string url, std::map<std::string, std::string> postData, APIResultParser * parser, ListenerHandle listener, int identifier):
|
APIRequest::APIRequest(ByteString url, std::map<ByteString, ByteString> postData, APIResultParser * parser, ListenerHandle listener, int identifier):
|
||||||
RequestBroker::Request(API, listener, identifier)
|
RequestBroker::Request(API, listener, identifier)
|
||||||
{
|
{
|
||||||
Post = true;
|
Post = true;
|
||||||
@ -81,11 +81,11 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
|
|||||||
int * postLength = new int[PostData.size()];
|
int * postLength = new int[PostData.size()];
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
std::map<std::string, std::string>::iterator iter = PostData.begin();
|
std::map<ByteString, ByteString>::iterator iter = PostData.begin();
|
||||||
while(iter != PostData.end())
|
while(iter != PostData.end())
|
||||||
{
|
{
|
||||||
std::string name = iter->first;
|
ByteString name = iter->first;
|
||||||
std::string data = iter->second;
|
ByteString data = iter->second;
|
||||||
char * cName = new char[name.length() + 1];
|
char * cName = new char[name.length() + 1];
|
||||||
char * cData = new char[data.length() + 1];
|
char * cData = new char[data.length() + 1];
|
||||||
std::strcpy(cName, name.c_str());
|
std::strcpy(cName, name.c_str());
|
||||||
@ -103,7 +103,7 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
|
|||||||
User user = Client::Ref().GetAuthUser();
|
User user = Client::Ref().GetAuthUser();
|
||||||
char userName[12];
|
char userName[12];
|
||||||
char *userSession = new char[user.SessionID.length() + 1];
|
char *userSession = new char[user.SessionID.length() + 1];
|
||||||
std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
|
std::strcpy(userName, format::NumberToByteString<int>(user.UserID).c_str());
|
||||||
std::strcpy(userSession, user.SessionID.c_str());
|
std::strcpy(userSession, user.SessionID.c_str());
|
||||||
HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession);
|
HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession);
|
||||||
delete[] userSession;
|
delete[] userSession;
|
||||||
@ -122,7 +122,7 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
|
|||||||
User user = Client::Ref().GetAuthUser();
|
User user = Client::Ref().GetAuthUser();
|
||||||
char userName[12];
|
char userName[12];
|
||||||
char *userSession = new char[user.SessionID.length() + 1];
|
char *userSession = new char[user.SessionID.length() + 1];
|
||||||
std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
|
std::strcpy(userName, format::NumberToByteString<int>(user.UserID).c_str());
|
||||||
std::strcpy(userSession, user.SessionID.c_str());
|
std::strcpy(userSession, user.SessionID.c_str());
|
||||||
http_auth_headers(HTTPContext, userName, NULL, userSession);
|
http_auth_headers(HTTPContext, userName, NULL, userSession);
|
||||||
delete[] userSession;
|
delete[] userSession;
|
||||||
|
@ -7,11 +7,11 @@ class APIRequest: public RequestBroker::Request
|
|||||||
public:
|
public:
|
||||||
bool Post;
|
bool Post;
|
||||||
APIResultParser * Parser;
|
APIResultParser * Parser;
|
||||||
std::string URL;
|
ByteString URL;
|
||||||
std::map<std::string, std::string> PostData;
|
std::map<ByteString, ByteString> PostData;
|
||||||
void * HTTPContext;
|
void * HTTPContext;
|
||||||
APIRequest(std::string url, APIResultParser * parser, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
|
APIRequest(ByteString url, APIResultParser * parser, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
|
||||||
APIRequest(std::string url, std::map<std::string, std::string>, APIResultParser * parser, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
|
APIRequest(ByteString url, std::map<ByteString, ByteString>, APIResultParser * parser, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
|
||||||
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
|
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
|
||||||
virtual ~APIRequest();
|
virtual ~APIRequest();
|
||||||
virtual void Cleanup();
|
virtual void Cleanup();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
#include "client/HTTP.h"
|
#include "client/HTTP.h"
|
||||||
|
|
||||||
ImageRequest::ImageRequest(std::string url, int width, int height, ListenerHandle listener, int identifier):
|
ImageRequest::ImageRequest(ByteString url, int width, int height, ListenerHandle listener, int identifier):
|
||||||
Request(Image, listener, identifier)
|
Request(Image, listener, identifier)
|
||||||
{
|
{
|
||||||
URL = url;
|
URL = url;
|
||||||
@ -24,7 +24,7 @@ RequestBroker::ProcessResponse ImageRequest::Process(RequestBroker & rb)
|
|||||||
VideoBuffer * image = NULL;
|
VideoBuffer * image = NULL;
|
||||||
|
|
||||||
//Have a look at the thumbnail cache
|
//Have a look at the thumbnail cache
|
||||||
for(std::deque<std::pair<std::string, VideoBuffer*> >::iterator iter = rb.imageCache.begin(), end = rb.imageCache.end(); iter != end; ++iter)
|
for(std::deque<std::pair<ByteString, VideoBuffer*> >::iterator iter = rb.imageCache.begin(), end = rb.imageCache.end(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
if((*iter).first == URL)
|
if((*iter).first == URL)
|
||||||
{
|
{
|
||||||
@ -71,7 +71,7 @@ RequestBroker::ProcessResponse ImageRequest::Process(RequestBroker & rb)
|
|||||||
delete rb.imageCache.front().second;
|
delete rb.imageCache.front().second;
|
||||||
rb.imageCache.pop_front();
|
rb.imageCache.pop_front();
|
||||||
}
|
}
|
||||||
rb.imageCache.push_back(std::pair<std::string, VideoBuffer*>(URL, image));
|
rb.imageCache.push_back(std::pair<ByteString, VideoBuffer*>(URL, image));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4,11 +4,11 @@ class ImageRequest: public RequestBroker::Request
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int Width, Height;
|
int Width, Height;
|
||||||
std::string URL;
|
ByteString URL;
|
||||||
int RequestTime;
|
int RequestTime;
|
||||||
void * HTTPContext;
|
void * HTTPContext;
|
||||||
bool started = false;
|
bool started = false;
|
||||||
ImageRequest(std::string url, int width, int height, ListenerHandle listener, int identifier = 0);
|
ImageRequest(ByteString url, int width, int height, ListenerHandle listener, int identifier = 0);
|
||||||
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
|
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
|
||||||
virtual ~ImageRequest();
|
virtual ~ImageRequest();
|
||||||
virtual void Cleanup();
|
virtual void Cleanup();
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <sstream>
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include "RequestBroker.h"
|
#include "RequestBroker.h"
|
||||||
#include "RequestListener.h"
|
#include "RequestListener.h"
|
||||||
@ -35,7 +34,7 @@ RequestBroker::RequestBroker()
|
|||||||
|
|
||||||
RequestBroker::~RequestBroker()
|
RequestBroker::~RequestBroker()
|
||||||
{
|
{
|
||||||
for(std::deque<std::pair<std::string, VideoBuffer*> >::iterator iter = imageCache.begin(), end = imageCache.end(); iter != end; ++iter)
|
for(std::deque<std::pair<ByteString, VideoBuffer*> >::iterator iter = imageCache.begin(), end = imageCache.end(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
delete (*iter).second;
|
delete (*iter).second;
|
||||||
}
|
}
|
||||||
@ -98,7 +97,7 @@ void RequestBroker::RenderThumbnail(GameSave * gameSave, bool decorations, bool
|
|||||||
|
|
||||||
void RequestBroker::RetrieveThumbnail(int saveID, int saveDate, int width, int height, RequestListener * tListener)
|
void RequestBroker::RetrieveThumbnail(int saveID, int saveDate, int width, int height, RequestListener * tListener)
|
||||||
{
|
{
|
||||||
std::stringstream urlStream;
|
ByteString::Stream urlStream;
|
||||||
urlStream << "http://" << STATICSERVER << "/" << saveID;
|
urlStream << "http://" << STATICSERVER << "/" << saveID;
|
||||||
if(saveDate)
|
if(saveDate)
|
||||||
{
|
{
|
||||||
@ -109,9 +108,9 @@ void RequestBroker::RetrieveThumbnail(int saveID, int saveDate, int width, int h
|
|||||||
RetrieveImage(urlStream.str(), width, height, tListener);
|
RetrieveImage(urlStream.str(), width, height, tListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestBroker::RetrieveAvatar(std::string username, int width, int height, RequestListener * tListener)
|
void RequestBroker::RetrieveAvatar(ByteString username, int width, int height, RequestListener * tListener)
|
||||||
{
|
{
|
||||||
std::stringstream urlStream;
|
ByteString::Stream urlStream;
|
||||||
urlStream << "http://" << STATICSERVER << "/avatars/" << username << ".pti";
|
urlStream << "http://" << STATICSERVER << "/avatars/" << username << ".pti";
|
||||||
|
|
||||||
RetrieveImage(urlStream.str(), width, height, tListener);
|
RetrieveImage(urlStream.str(), width, height, tListener);
|
||||||
@ -130,7 +129,7 @@ void RequestBroker::Start(Request * request, RequestListener * tListener, int id
|
|||||||
assureRunning();
|
assureRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestBroker::RetrieveImage(std::string imageUrl, int width, int height, RequestListener * tListener)
|
void RequestBroker::RetrieveImage(ByteString imageUrl, int width, int height, RequestListener * tListener)
|
||||||
{
|
{
|
||||||
ListenerHandle handle = AttachRequestListener(tListener);
|
ListenerHandle handle = AttachRequestListener(tListener);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "common/tpt-thread.h"
|
#include "common/tpt-thread.h"
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
@ -33,7 +33,7 @@ private:
|
|||||||
|
|
||||||
std::vector<ListenerHandle> validListeners;
|
std::vector<ListenerHandle> validListeners;
|
||||||
|
|
||||||
std::deque<std::pair<std::string, VideoBuffer*> > imageCache;
|
std::deque<std::pair<ByteString, VideoBuffer*> > imageCache;
|
||||||
|
|
||||||
std::queue<Request*> completeQueue;
|
std::queue<Request*> completeQueue;
|
||||||
std::vector<Request*> requestQueue;
|
std::vector<Request*> requestQueue;
|
||||||
@ -51,12 +51,12 @@ public:
|
|||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
void FlushThumbQueue();
|
void FlushThumbQueue();
|
||||||
void RetrieveImage(std::string imageUrl, int width, int height, RequestListener * tListener);
|
void RetrieveImage(ByteString imageUrl, int width, int height, RequestListener * tListener);
|
||||||
void RenderThumbnail(GameSave * gameSave, bool decorations, bool fire, int width, int height, RequestListener * tListener);
|
void RenderThumbnail(GameSave * gameSave, bool decorations, bool fire, int width, int height, RequestListener * tListener);
|
||||||
void RenderThumbnail(GameSave * gameSave, int width, int height, RequestListener * tListener);
|
void RenderThumbnail(GameSave * gameSave, int width, int height, RequestListener * tListener);
|
||||||
void RetrieveThumbnail(int saveID, int saveDate, int width, int height, RequestListener * tListener);
|
void RetrieveThumbnail(int saveID, int saveDate, int width, int height, RequestListener * tListener);
|
||||||
void RetrieveThumbnail(int saveID, int width, int height, RequestListener * tListener);
|
void RetrieveThumbnail(int saveID, int width, int height, RequestListener * tListener);
|
||||||
void RetrieveAvatar(std::string username, int width, int height, RequestListener * tListener);
|
void RetrieveAvatar(ByteString username, int width, int height, RequestListener * tListener);
|
||||||
void Start(Request * request, RequestListener * tLIstener, int identifier = 0);
|
void Start(Request * request, RequestListener * tLIstener, int identifier = 0);
|
||||||
|
|
||||||
bool CheckRequestListener(ListenerHandle handle);
|
bool CheckRequestListener(ListenerHandle handle);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "client/HTTP.h"
|
#include "client/HTTP.h"
|
||||||
#include "APIResultParser.h"
|
#include "APIResultParser.h"
|
||||||
|
|
||||||
WebRequest::WebRequest(std::string url, ListenerHandle listener, int identifier):
|
WebRequest::WebRequest(ByteString url, ListenerHandle listener, int identifier):
|
||||||
RequestBroker::Request(API, listener, identifier)
|
RequestBroker::Request(API, listener, identifier)
|
||||||
{
|
{
|
||||||
Post = false;
|
Post = false;
|
||||||
@ -18,7 +18,7 @@ WebRequest::WebRequest(std::string url, ListenerHandle listener, int identifier)
|
|||||||
URL = url;
|
URL = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRequest::WebRequest(std::string url, std::map<std::string, std::string> postData, ListenerHandle listener, int identifier):
|
WebRequest::WebRequest(ByteString url, std::map<ByteString, ByteString> postData, ListenerHandle listener, int identifier):
|
||||||
RequestBroker::Request(API, listener, identifier)
|
RequestBroker::Request(API, listener, identifier)
|
||||||
{
|
{
|
||||||
Post = true;
|
Post = true;
|
||||||
@ -81,11 +81,11 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
|
|||||||
int * postLength = new int[PostData.size()];
|
int * postLength = new int[PostData.size()];
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
std::map<std::string, std::string>::iterator iter = PostData.begin();
|
std::map<ByteString, ByteString>::iterator iter = PostData.begin();
|
||||||
while(iter != PostData.end())
|
while(iter != PostData.end())
|
||||||
{
|
{
|
||||||
std::string name = iter->first;
|
ByteString name = iter->first;
|
||||||
std::string data = iter->second;
|
ByteString data = iter->second;
|
||||||
char * cName = new char[name.length() + 1];
|
char * cName = new char[name.length() + 1];
|
||||||
char * cData = new char[data.length() + 1];
|
char * cData = new char[data.length() + 1];
|
||||||
std::strcpy(cName, name.c_str());
|
std::strcpy(cName, name.c_str());
|
||||||
@ -106,7 +106,7 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
|
|||||||
User user = Client::Ref().GetAuthUser();
|
User user = Client::Ref().GetAuthUser();
|
||||||
char userName[12];
|
char userName[12];
|
||||||
char *userSession = new char[user.SessionID.length() + 1];
|
char *userSession = new char[user.SessionID.length() + 1];
|
||||||
std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
|
std::strcpy(userName, format::NumberToByteString<int>(user.UserID).c_str());
|
||||||
std::strcpy(userSession, user.SessionID.c_str());
|
std::strcpy(userSession, user.SessionID.c_str());
|
||||||
HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession);
|
HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession);
|
||||||
delete[] userSession;
|
delete[] userSession;
|
||||||
@ -125,7 +125,7 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
|
|||||||
User user = Client::Ref().GetAuthUser();
|
User user = Client::Ref().GetAuthUser();
|
||||||
char userName[12];
|
char userName[12];
|
||||||
char *userSession = new char[user.SessionID.length() + 1];
|
char *userSession = new char[user.SessionID.length() + 1];
|
||||||
std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
|
std::strcpy(userName, format::NumberToByteString<int>(user.UserID).c_str());
|
||||||
std::strcpy(userSession, user.SessionID.c_str());
|
std::strcpy(userSession, user.SessionID.c_str());
|
||||||
http_auth_headers(HTTPContext, userName, NULL, userSession);
|
http_auth_headers(HTTPContext, userName, NULL, userSession);
|
||||||
delete[] userSession;
|
delete[] userSession;
|
||||||
|
@ -5,11 +5,11 @@ class WebRequest: public RequestBroker::Request
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool Post;
|
bool Post;
|
||||||
std::string URL;
|
ByteString URL;
|
||||||
std::map<std::string, std::string> PostData;
|
std::map<ByteString, ByteString> PostData;
|
||||||
void * HTTPContext;
|
void * HTTPContext;
|
||||||
WebRequest(std::string url, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
|
WebRequest(ByteString url, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
|
||||||
WebRequest(std::string url, std::map<std::string, std::string>, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
|
WebRequest(ByteString url, std::map<ByteString, ByteString>, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
|
||||||
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
|
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
|
||||||
virtual ~WebRequest();
|
virtual ~WebRequest();
|
||||||
virtual void Cleanup();
|
virtual void Cleanup();
|
||||||
|
@ -87,3 +87,135 @@ ByteString String::ToUtf8() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> std::ctype<char32_t>::~ctype()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
template<> std::numpunct<char32_t>::numpunct(size_t ref): std::locale::facet(ref)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
template<> std::numpunct<char32_t>::~numpunct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct Locale32Impl
|
||||||
|
{
|
||||||
|
std::ctype<wchar_t> const &ctype16;
|
||||||
|
std::numpunct<wchar_t> const &numpunct16;
|
||||||
|
Locale32Impl():
|
||||||
|
ctype16(std::use_facet<std::ctype<wchar_t> >(std::locale())),
|
||||||
|
numpunct16(std::use_facet<std::numpunct<wchar_t> >(std::locale()))
|
||||||
|
{
|
||||||
|
std::locale::global(std::locale(std::locale(), new std::ctype<char32_t>()));
|
||||||
|
std::locale::global(std::locale(std::locale(), new std::numpunct<char32_t>()));
|
||||||
|
std::locale::global(std::locale(std::locale(), new std::num_put<char32_t>()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Locale32Impl;
|
||||||
|
|
||||||
|
template<> bool std::ctype<char32_t>::do_is(mask m, char32_t ch) const
|
||||||
|
{
|
||||||
|
return ch <= 0xFFFF ? Locale32Impl.ctype16.is(m, ch) : (m & print);
|
||||||
|
}
|
||||||
|
template<> char32_t const *std::ctype<char32_t>::do_is(char32_t const *low, char32_t const *high, mask *vec) const
|
||||||
|
{
|
||||||
|
while(low < high)
|
||||||
|
{
|
||||||
|
if(*low <= 0xFFFF)
|
||||||
|
{
|
||||||
|
wchar_t l = *low;
|
||||||
|
Locale32Impl.ctype16.is(&l, &l + 1, vec);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*vec = print;
|
||||||
|
low++;
|
||||||
|
}
|
||||||
|
return high;
|
||||||
|
}
|
||||||
|
template<> char32_t const *std::ctype<char32_t>::do_scan_is(mask m, char32_t const *beg, char32_t const *end) const
|
||||||
|
{
|
||||||
|
while(beg < end)
|
||||||
|
if(do_is(m, *beg))
|
||||||
|
return beg;
|
||||||
|
else
|
||||||
|
beg++;
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
template<> char32_t const *std::ctype<char32_t>::do_scan_not(mask m, char32_t const *beg, char32_t const *end) const
|
||||||
|
{
|
||||||
|
while(beg < end)
|
||||||
|
if(!do_is(m, *beg))
|
||||||
|
return beg;
|
||||||
|
else
|
||||||
|
beg++;
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
template<> char32_t std::ctype<char32_t>::do_toupper(char32_t ch) const
|
||||||
|
{
|
||||||
|
return ch <= 0xFFFF ? Locale32Impl.ctype16.toupper(ch) : ch;
|
||||||
|
}
|
||||||
|
template<> char32_t const *std::ctype<char32_t>::do_toupper(char32_t *beg, char32_t const *end) const
|
||||||
|
{
|
||||||
|
while(beg < end)
|
||||||
|
{
|
||||||
|
*beg = do_toupper(*beg);
|
||||||
|
beg++;
|
||||||
|
}
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
template<> char32_t std::ctype<char32_t>::do_tolower(char32_t ch) const
|
||||||
|
{
|
||||||
|
return ch <= 0xFFFF ? Locale32Impl.ctype16.tolower(ch) : ch;
|
||||||
|
}
|
||||||
|
template<> char32_t const *std::ctype<char32_t>::do_tolower(char32_t *beg, char32_t const *end) const
|
||||||
|
{
|
||||||
|
while(beg < end)
|
||||||
|
{
|
||||||
|
*beg = do_tolower(*beg);
|
||||||
|
beg++;
|
||||||
|
}
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
template<> char32_t std::ctype<char32_t>::do_widen(char ch) const
|
||||||
|
{
|
||||||
|
return Locale32Impl.ctype16.widen(ch);
|
||||||
|
}
|
||||||
|
template<> char const *std::ctype<char32_t>::do_widen(char const *beg, char const *end, char32_t *dst) const
|
||||||
|
{
|
||||||
|
while(beg < end)
|
||||||
|
*(dst++) = do_widen(*(beg++));
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
template<> char std::ctype<char32_t>::do_narrow(char32_t ch, char dflt) const
|
||||||
|
{
|
||||||
|
return ch <= 0xFFFF ? Locale32Impl.ctype16.narrow(ch, dflt) : dflt;
|
||||||
|
}
|
||||||
|
template<> char32_t const *std::ctype<char32_t>::do_narrow(char32_t const *beg, char32_t const *end, char dflt, char *dst) const
|
||||||
|
{
|
||||||
|
while(beg < end)
|
||||||
|
*(dst++) = do_narrow(*(beg++), dflt);
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> char32_t std::numpunct<char32_t>::do_decimal_point() const
|
||||||
|
{
|
||||||
|
return Locale32Impl.numpunct16.decimal_point();
|
||||||
|
}
|
||||||
|
template<> char32_t std::numpunct<char32_t>::do_thousands_sep() const
|
||||||
|
{
|
||||||
|
return Locale32Impl.numpunct16.thousands_sep();
|
||||||
|
}
|
||||||
|
template<> std::string std::numpunct<char32_t>::do_grouping() const
|
||||||
|
{
|
||||||
|
return Locale32Impl.numpunct16.grouping();
|
||||||
|
}
|
||||||
|
template<> std::basic_string<char32_t> std::numpunct<char32_t>::do_truename() const
|
||||||
|
{
|
||||||
|
std::basic_string<wchar_t> name = Locale32Impl.numpunct16.truename();
|
||||||
|
return std::basic_string<char32_t>(name.begin(), name.end());
|
||||||
|
}
|
||||||
|
template<> std::basic_string<char32_t> std::numpunct<char32_t>::do_falsename() const
|
||||||
|
{
|
||||||
|
std::basic_string<wchar_t> name = Locale32Impl.numpunct16.falsename();
|
||||||
|
return std::basic_string<char32_t>(name.begin(), name.end());
|
||||||
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef TPT_STRING
|
#ifndef TPT_STRING
|
||||||
#define TPT_STRING
|
#define TPT_STRING
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class String;
|
class String;
|
||||||
@ -13,11 +15,18 @@ public:
|
|||||||
inline ByteString(value_type const *ch, size_type count): std::basic_string<char>(ch, count) {}
|
inline ByteString(value_type const *ch, size_type count): std::basic_string<char>(ch, count) {}
|
||||||
inline ByteString(value_type const *ch): std::basic_string<char>(ch) {}
|
inline ByteString(value_type const *ch): std::basic_string<char>(ch) {}
|
||||||
template<class It> inline ByteString(It first, It last): std::basic_string<char>(first, last) {}
|
template<class It> inline ByteString(It first, It last): std::basic_string<char>(first, last) {}
|
||||||
|
inline ByteString(std::basic_string<char> const &other): std::basic_string<char>(other) {}
|
||||||
|
inline ByteString(std::basic_string<char> &&other): std::basic_string<char>(std::move(other)) {}
|
||||||
inline ByteString(ByteString const &other): std::basic_string<char>(other) {}
|
inline ByteString(ByteString const &other): std::basic_string<char>(other) {}
|
||||||
inline ByteString(ByteString &&other): std::basic_string<char>(std::move(other)) {}
|
inline ByteString(ByteString &&other): std::basic_string<char>(std::move(other)) {}
|
||||||
|
|
||||||
ByteString &operator=(ByteString const &other) { std::basic_string<char>::operator=(other); return *this; }
|
inline ByteString &operator=(ByteString const &other) { std::basic_string<char>::operator=(other); return *this; }
|
||||||
ByteString &operator=(ByteString &&other) { std::basic_string<char>::operator=(std::move(other)); return *this; }
|
inline ByteString &operator=(ByteString &&other) { std::basic_string<char>::operator=(std::move(other)); return *this; }
|
||||||
|
|
||||||
|
template<typename T> ByteString &operator+=(T &&other) { std::basic_string<char>::operator+=(std::forward<T>(other)); return *this; }
|
||||||
|
template<typename T> inline ByteString operator+(T &&other) const { ByteString tmp = *this; tmp += std::forward<T>(other); return tmp; }
|
||||||
|
template<typename... Ts> ByteString substr(Ts&&... args) const { return std::basic_string<char>::substr(std::forward<Ts>(args)...); }
|
||||||
|
template<typename... Ts> ByteString &insert(Ts&&... args) { std::basic_string<char>::insert(std::forward<Ts>(args)...); return *this; }
|
||||||
|
|
||||||
class ConversionError : public std::runtime_error
|
class ConversionError : public std::runtime_error
|
||||||
{
|
{
|
||||||
@ -29,8 +38,14 @@ public:
|
|||||||
|
|
||||||
String FromUtf8(bool ignoreError = true) const;
|
String FromUtf8(bool ignoreError = true) const;
|
||||||
inline String FromAscii() const;
|
inline String FromAscii() const;
|
||||||
|
|
||||||
|
using Stream = std::basic_stringstream<value_type>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline ByteString operator+(ByteString::value_type const *ch, ByteString const &str) { return ByteString(ch) + str; }
|
||||||
|
inline ByteString operator+(std::basic_string<char> const &other, ByteString const &str) { return ByteString(other) + str; }
|
||||||
|
inline ByteString operator+(std::basic_string<char> &&other, ByteString const &str) { return ByteString(std::move(other)) + str; }
|
||||||
|
|
||||||
class String : public std::basic_string<char32_t>
|
class String : public std::basic_string<char32_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -39,22 +54,52 @@ public:
|
|||||||
inline String(value_type const *ch, size_type count): std::basic_string<char32_t>(ch, count) {}
|
inline String(value_type const *ch, size_type count): std::basic_string<char32_t>(ch, count) {}
|
||||||
inline String(value_type const *ch): std::basic_string<char32_t>(ch) {}
|
inline String(value_type const *ch): std::basic_string<char32_t>(ch) {}
|
||||||
template<class It> inline String(It first, It last): std::basic_string<char32_t>(first, last) {}
|
template<class It> inline String(It first, It last): std::basic_string<char32_t>(first, last) {}
|
||||||
|
inline String(std::basic_string<char32_t> const &other): std::basic_string<char32_t>(other) {}
|
||||||
|
inline String(std::basic_string<char32_t> &&other): std::basic_string<char32_t>(std::move(other)) {}
|
||||||
inline String(String const &other): std::basic_string<char32_t>(other) {}
|
inline String(String const &other): std::basic_string<char32_t>(other) {}
|
||||||
inline String(String &&other): std::basic_string<char32_t>(std::move(other)) {}
|
inline String(String &&other): std::basic_string<char32_t>(std::move(other)) {}
|
||||||
|
template<unsigned N> inline String(ByteString::value_type const (&ch)[N]): std::basic_string<char32_t>(ByteString(ch, N - 1).FromAscii()) {}
|
||||||
|
|
||||||
String &operator=(String const &other) { std::basic_string<char32_t>::operator=(other); return *this; }
|
inline String &operator=(String const &other) { std::basic_string<char32_t>::operator=(other); return *this; }
|
||||||
String &operator=(String &&other) { std::basic_string<char32_t>::operator=(std::move(other)); return *this; }
|
inline String &operator=(String &&other) { std::basic_string<char32_t>::operator=(other); return *this; }
|
||||||
|
|
||||||
|
template<typename T> inline String &operator+=(T &&other) { std::basic_string<char32_t>::operator+=(std::forward<T>(other)); return *this; }
|
||||||
|
template<unsigned N> inline String &operator+=(ByteString::value_type const (&ch)[N]) { std::basic_string<char32_t>::operator+=(ByteString(ch, N - 1).FromAscii()); return *this; }
|
||||||
|
template<typename T> inline String operator+(T &&other) const { String tmp = *this; tmp += std::forward<T>(other); return tmp; }
|
||||||
|
template<typename... Ts> inline String substr(Ts&&... args) const { return std::basic_string<char32_t>::substr(std::forward<Ts>(args)...); }
|
||||||
|
inline String &insert(size_t pos, String &str) { std::basic_string<char32_t>::insert(pos, str); return *this; }
|
||||||
|
inline String &insert(size_t pos, size_t n, value_type ch) { std::basic_string<char32_t>::insert(pos, n, ch); return *this; }
|
||||||
|
template<unsigned N> inline String &insert(size_t pos, ByteString::value_type const (&ch)[N]) { std::basic_string<char32_t>::insert(pos, ByteString(ch, N - 1).FromAscii()); return *this; }
|
||||||
|
inline size_t find(String const &str, size_t pos = 0) { return std::basic_string<char32_t>::find(str, pos); }
|
||||||
|
inline size_t find(value_type ch, size_t pos = 0) { return std::basic_string<char32_t>::find(ch, pos); }
|
||||||
|
|
||||||
template<unsigned N> inline String(ByteString::value_type const (&ch)[N]): std::basic_string<char32_t>(ByteString(ch, N).FromAscii()) {}
|
inline bool operator==(String const &other) { return std::basic_string<char32_t>(*this) == other; }
|
||||||
|
|
||||||
ByteString ToUtf8() const;
|
ByteString ToUtf8() const;
|
||||||
|
ByteString ToAscii() const;
|
||||||
|
|
||||||
|
using Stream = std::basic_stringstream<value_type>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline String operator+(String::value_type const *ch, String const &str) { return String(ch) + str; }
|
||||||
|
inline String operator+(std::basic_string<char32_t> const &other, String const &str) { return String(other) + str; }
|
||||||
|
inline String operator+(std::basic_string<char32_t> &&other, String const &str) { return String(std::move(other)) + str; }
|
||||||
|
template<unsigned N> inline String operator+(ByteString::value_type const (&ch)[N], String const &str) { return String(ch) + str; }
|
||||||
|
|
||||||
|
|
||||||
inline String ByteString::FromAscii() const
|
inline String ByteString::FromAscii() const
|
||||||
{
|
{
|
||||||
String destination = String(size(), String::value_type());
|
String destination = String(size(), String::value_type());
|
||||||
for(size_t i = 0; i < size(); i++)
|
for(size_t i = 0; i < size(); i++)
|
||||||
destination[i] = typename String::value_type(operator[](i));
|
destination[i] = String::value_type(std::make_unsigned<ByteString::value_type>::type(operator[](i)));
|
||||||
|
return destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ByteString String::ToAscii() const
|
||||||
|
{
|
||||||
|
ByteString destination = ByteString(size(), ByteString::value_type());
|
||||||
|
for(size_t i = 0; i < size(); i++)
|
||||||
|
destination[i] = ByteString::value_type(operator[](i));
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,21 +27,21 @@ void DebugLines::Draw()
|
|||||||
g->draw_line(0, drawPoint2.Y, XRES, drawPoint2.Y, 255, 255, 255, 120);
|
g->draw_line(0, drawPoint2.Y, XRES, drawPoint2.Y, 255, 255, 255, 120);
|
||||||
g->draw_line(drawPoint2.X, 0, drawPoint2.X, YRES, 255, 255, 255, 120);
|
g->draw_line(drawPoint2.X, 0, drawPoint2.X, YRES, 255, 255, 255, 120);
|
||||||
|
|
||||||
std::stringstream info;
|
String::Stream info;
|
||||||
info << drawPoint2.X << " x " << drawPoint2.Y;
|
info << drawPoint2.X << " x " << drawPoint2.Y;
|
||||||
g->drawtext_outline(drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-g->textwidth(info.str().c_str())-3), drawPoint2.Y+(drawPoint2.Y<drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200);
|
g->drawtext_outline(drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-g->textwidth(info.str())-3), drawPoint2.Y+(drawPoint2.Y<drawPoint1.Y?-10:3), info.str(), 255, 255, 255, 200);
|
||||||
|
|
||||||
info.str("");
|
info.str(String());
|
||||||
info << drawPoint1.X << " x " << drawPoint1.Y;
|
info << drawPoint1.X << " x " << drawPoint1.Y;
|
||||||
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info.str().c_str())-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200);
|
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info.str())-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info.str(), 255, 255, 255, 200);
|
||||||
|
|
||||||
info.str("");
|
info.str(String());
|
||||||
info << std::abs(drawPoint2.X-drawPoint1.X);
|
info << std::abs(drawPoint2.X-drawPoint1.X);
|
||||||
g->drawtext_outline((drawPoint1.X+drawPoint2.X)/2-g->textwidth(info.str().c_str())/2, drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200);
|
g->drawtext_outline((drawPoint1.X+drawPoint2.X)/2-g->textwidth(info.str())/2, drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info.str(), 255, 255, 255, 200);
|
||||||
|
|
||||||
info.str("");
|
info.str(String());
|
||||||
info << std::abs(drawPoint2.Y-drawPoint1.Y);
|
info << std::abs(drawPoint2.Y-drawPoint1.Y);
|
||||||
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info.str().c_str())-2), (drawPoint1.Y+drawPoint2.Y)/2-3, info.str().c_str(), 255, 255, 255, 200);
|
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info.str())-2), (drawPoint1.Y+drawPoint2.Y)/2-3, info.str(), 255, 255, 255, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
|
||||||
#include "DebugParts.h"
|
#include "DebugParts.h"
|
||||||
#include "gui/interface/Engine.h"
|
#include "gui/interface/Engine.h"
|
||||||
#include "simulation/Simulation.h"
|
#include "simulation/Simulation.h"
|
||||||
@ -16,7 +15,7 @@ void DebugParts::Draw()
|
|||||||
Graphics * g = ui::Engine::Ref().g;
|
Graphics * g = ui::Engine::Ref().g;
|
||||||
|
|
||||||
int x = 0, y = 0, lpx = 0, lpy = 0;
|
int x = 0, y = 0, lpx = 0, lpy = 0;
|
||||||
std::stringstream info;
|
String::Stream info;
|
||||||
info << sim->parts_lastActiveIndex << "/" << NPART << " (" << std::fixed << std::setprecision(2) << (float)sim->parts_lastActiveIndex/(NPART)*100.0f << "%)";
|
info << sim->parts_lastActiveIndex << "/" << NPART << " (" << std::fixed << std::setprecision(2) << (float)sim->parts_lastActiveIndex/(NPART)*100.0f << "%)";
|
||||||
for (int i = 0; i < NPART; i++)
|
for (int i = 0; i < NPART; i++)
|
||||||
{
|
{
|
||||||
@ -46,8 +45,8 @@ void DebugParts::Draw()
|
|||||||
g->addpixel(lpx, lpy+1, 255, 50, 50, 120);
|
g->addpixel(lpx, lpy+1, 255, 50, 50, 120);
|
||||||
g->addpixel(lpx, lpy-1, 255, 50, 50, 120);
|
g->addpixel(lpx, lpy-1, 255, 50, 50, 120);
|
||||||
|
|
||||||
g->fillrect(7, YRES-26, g->textwidth(info.str().c_str())+5, 14, 0, 0, 0, 180);
|
g->fillrect(7, YRES-26, g->textwidth(info.str())+5, 14, 0, 0, 0, 180);
|
||||||
g->drawtext(10, YRES-22, info.str().c_str(), 255, 255, 255, 255);
|
g->drawtext(10, YRES-22, info.str(), 255, 255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugParts::~DebugParts()
|
DebugParts::~DebugParts()
|
||||||
|
@ -18,8 +18,8 @@ void ElementPopulationDebug::Draw()
|
|||||||
int yBottom = YRES-10;
|
int yBottom = YRES-10;
|
||||||
int xStart = 10;
|
int xStart = 10;
|
||||||
|
|
||||||
std::string maxValString;
|
String maxValString;
|
||||||
std::string halfValString;
|
String halfValString;
|
||||||
|
|
||||||
|
|
||||||
float maxVal = 255;
|
float maxVal = 255;
|
||||||
@ -41,7 +41,7 @@ void ElementPopulationDebug::Draw()
|
|||||||
halfValString = format::NumberToString<int>(maxAverage/2);
|
halfValString = format::NumberToString<int>(maxAverage/2);
|
||||||
|
|
||||||
|
|
||||||
g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::textwidth(maxValString.c_str())+10, 255 + 13, 0, 0, 0, 180);
|
g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::textwidth(maxValString)+10, 255 + 13, 0, 0, 0, 180);
|
||||||
|
|
||||||
bars = 0;
|
bars = 0;
|
||||||
for(int i = 0; i < PT_NUM; i++)
|
for(int i = 0; i < PT_NUM; i++)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <sstream>
|
|
||||||
#include "ParticleDebug.h"
|
#include "ParticleDebug.h"
|
||||||
#include "gui/interface/Engine.h"
|
#include "gui/interface/Engine.h"
|
||||||
#include "gui/game/GameView.h"
|
#include "gui/game/GameView.h"
|
||||||
@ -16,7 +15,7 @@ void ParticleDebug::Debug(int mode, int x, int y)
|
|||||||
{
|
{
|
||||||
int debug_currentParticle = sim->debug_currentParticle;
|
int debug_currentParticle = sim->debug_currentParticle;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
std::stringstream logmessage;
|
String::Stream logmessage;
|
||||||
|
|
||||||
if (mode == 0)
|
if (mode == 0)
|
||||||
{
|
{
|
||||||
@ -90,7 +89,7 @@ bool ParticleDebug::KeyPress(int key, Uint16 character, bool shift, bool ctrl, b
|
|||||||
{
|
{
|
||||||
sim->UpdateParticles(sim->debug_currentParticle, NPART);
|
sim->UpdateParticles(sim->debug_currentParticle, NPART);
|
||||||
sim->AfterSim();
|
sim->AfterSim();
|
||||||
std::stringstream logmessage;
|
String::Stream logmessage;
|
||||||
logmessage << "Updated particles from #" << sim->debug_currentParticle << " to end, updated sim";
|
logmessage << "Updated particles from #" << sim->debug_currentParticle << " to end, updated sim";
|
||||||
model->Log(logmessage.str(), false);
|
model->Log(logmessage.str(), false);
|
||||||
sim->debug_currentParticle = 0;
|
sim->debug_currentParticle = 0;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
int drawtext(int x, int y, const char *s, int r, int g, int b, int a);
|
int drawtext(int x, int y, String s, int r, int g, int b, int a);
|
||||||
int drawtext(int x, int y, std::string s, int r, int g, int b, int a);
|
int drawchar(int x, int y, String::value_type c, int r, int g, int b, int a);
|
||||||
int drawchar(int x, int y, int c, int r, int g, int b, int a);
|
int addchar(int x, int y, String::value_type c, int r, int g, int b, int a);
|
||||||
int addchar(int x, int y, int c, int r, int g, int b, int a);
|
|
||||||
|
|
||||||
void xor_pixel(int x, int y);
|
void xor_pixel(int x, int y);
|
||||||
void xor_line(int x, int y, int x2, int y2);
|
void xor_line(int x, int y, int x2, int y2);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <bzlib.h>
|
#include <bzlib.h>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Misc.h"
|
#include "Misc.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
@ -566,9 +566,10 @@ pixel *Graphics::rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Graphics::textwidth(const char *s)
|
int Graphics::textwidth(String str)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
String::value_type const *s = str.c_str();
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
if(((char)*s)=='\b')
|
if(((char)*s)=='\b')
|
||||||
@ -581,19 +582,20 @@ int Graphics::textwidth(const char *s)
|
|||||||
s+=3;
|
s+=3;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
x += font_data[font_ptrs[*s]];
|
||||||
}
|
}
|
||||||
return x-1;
|
return x-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Graphics::CharWidth(unsigned char c)
|
int Graphics::CharWidth(String::value_type c)
|
||||||
{
|
{
|
||||||
return font_data[font_ptrs[(int)c]];
|
return font_data[font_ptrs[(int)c]];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Graphics::textnwidth(char *s, int n)
|
int Graphics::textnwidth(String str, int n)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
String::value_type const *s = str.c_str();
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
if (!n)
|
if (!n)
|
||||||
@ -608,20 +610,23 @@ int Graphics::textnwidth(char *s, int n)
|
|||||||
s+=3;
|
s+=3;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
x += font_data[font_ptrs[*s]];
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
return x-1;
|
return x-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::textnpos(char *s, int n, int w, int *cx, int *cy)
|
void Graphics::textnpos(String str, int n, int w, int *cx, int *cy)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
int wordlen, charspace;
|
int wordlen, charspace;
|
||||||
|
String::value_type const *s = str.c_str();
|
||||||
while (*s&&n)
|
while (*s&&n)
|
||||||
{
|
{
|
||||||
wordlen = strcspn(s," .,!?\n");
|
wordlen = 0;
|
||||||
|
while(*s && String(" .,!?\n").find(*s) != String::npos)
|
||||||
|
s++;
|
||||||
charspace = textwidthx(s, w-x);
|
charspace = textwidthx(s, w-x);
|
||||||
if (charspace<wordlen && wordlen && w-x<w/3)
|
if (charspace<wordlen && wordlen && w-x<w/3)
|
||||||
{
|
{
|
||||||
@ -633,7 +638,7 @@ void Graphics::textnpos(char *s, int n, int w, int *cx, int *cy)
|
|||||||
if (!n) {
|
if (!n) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
x += font_data[font_ptrs[*s]];
|
||||||
if (x>=w)
|
if (x>=w)
|
||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
@ -646,9 +651,10 @@ void Graphics::textnpos(char *s, int n, int w, int *cx, int *cy)
|
|||||||
*cy = y;
|
*cy = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Graphics::textwidthx(char *s, int w)
|
int Graphics::textwidthx(String str, int w)
|
||||||
{
|
{
|
||||||
int x=0,n=0,cw;
|
int x=0,n=0,cw;
|
||||||
|
String::value_type const *s = str.c_str();
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
if((char)*s == '\b')
|
if((char)*s == '\b')
|
||||||
@ -662,7 +668,7 @@ int Graphics::textwidthx(char *s, int w)
|
|||||||
s+=3;
|
s+=3;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
cw = font_data[font_ptrs[*s]];
|
||||||
if (x+(cw/2) >= w)
|
if (x+(cw/2) >= w)
|
||||||
break;
|
break;
|
||||||
x += cw;
|
x += cw;
|
||||||
@ -671,9 +677,10 @@ int Graphics::textwidthx(char *s, int w)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Graphics::PositionAtCharIndex(char *s, int charIndex, int & positionX, int & positionY)
|
int Graphics::PositionAtCharIndex(String str, int charIndex, int & positionX, int & positionY)
|
||||||
{
|
{
|
||||||
int x = 0, y = 0, lines = 1;
|
int x = 0, y = 0, lines = 1;
|
||||||
|
String::value_type const *s = str.c_str();
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
if (!charIndex)
|
if (!charIndex)
|
||||||
@ -695,7 +702,7 @@ int Graphics::PositionAtCharIndex(char *s, int charIndex, int & positionX, int &
|
|||||||
charIndex-=4;
|
charIndex-=4;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
x += font_data[font_ptrs[*s]];
|
||||||
charIndex--;
|
charIndex--;
|
||||||
}
|
}
|
||||||
positionX = x;
|
positionX = x;
|
||||||
@ -703,9 +710,10 @@ int Graphics::PositionAtCharIndex(char *s, int charIndex, int & positionX, int &
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Graphics::CharIndexAtPosition(char *s, int positionX, int positionY)
|
int Graphics::CharIndexAtPosition(String str, int positionX, int positionY)
|
||||||
{
|
{
|
||||||
int x=0, y=-2,charIndex=0,cw;
|
int x=0, y=-2,charIndex=0,cw;
|
||||||
|
String::value_type const *s = str.c_str();
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
if(*s == '\n') {
|
if(*s == '\n') {
|
||||||
@ -724,7 +732,7 @@ int Graphics::CharIndexAtPosition(char *s, int positionX, int positionY)
|
|||||||
charIndex+=4;
|
charIndex+=4;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
cw = font_data[font_ptrs[*s]];
|
||||||
if ((x+(cw/2) >= positionX && y+FONT_H >= positionY) || y > positionY)
|
if ((x+(cw/2) >= positionX && y+FONT_H >= positionY) || y > positionY)
|
||||||
break;
|
break;
|
||||||
x += cw;
|
x += cw;
|
||||||
@ -734,14 +742,17 @@ int Graphics::CharIndexAtPosition(char *s, int positionX, int positionY)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Graphics::textwrapheight(char *s, int width)
|
int Graphics::textwrapheight(String str, int width)
|
||||||
{
|
{
|
||||||
int x=0, height=FONT_H, cw;
|
int x=0, height=FONT_H, cw;
|
||||||
int wordlen;
|
int wordlen;
|
||||||
int charspace;
|
int charspace;
|
||||||
|
String::value_type const *s = str.c_str();
|
||||||
while (*s)
|
while (*s)
|
||||||
{
|
{
|
||||||
wordlen = strcspn(s," .,!?\n");
|
wordlen = 0;
|
||||||
|
while(*s && String(" .,!?\n").find(*s) != String::npos)
|
||||||
|
s++;
|
||||||
charspace = textwidthx(s, width-x);
|
charspace = textwidthx(s, width-x);
|
||||||
if (charspace<wordlen && wordlen && width-x<width/3)
|
if (charspace<wordlen && wordlen && width-x<width/3)
|
||||||
{
|
{
|
||||||
@ -767,7 +778,7 @@ int Graphics::textwrapheight(char *s, int width)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
cw = font_data[font_ptrs[*s]];
|
||||||
if (x+cw>=width)
|
if (x+cw>=width)
|
||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
@ -780,9 +791,9 @@ int Graphics::textwrapheight(char *s, int width)
|
|||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::textsize(const char * s, int & width, int & height)
|
void Graphics::textsize(String str, int & width, int & height)
|
||||||
{
|
{
|
||||||
if(!strlen(s))
|
if(!str.size())
|
||||||
{
|
{
|
||||||
width = 0;
|
width = 0;
|
||||||
height = FONT_H-2;
|
height = FONT_H-2;
|
||||||
@ -790,6 +801,7 @@ void Graphics::textsize(const char * s, int & width, int & height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int cHeight = FONT_H-2, cWidth = 0, lWidth = 0;
|
int cHeight = FONT_H-2, cWidth = 0, lWidth = 0;
|
||||||
|
String::value_type const *s = str.c_str();
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
if (*s == '\n')
|
if (*s == '\n')
|
||||||
@ -809,7 +821,7 @@ void Graphics::textsize(const char * s, int & width, int & height)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cWidth += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
cWidth += font_data[font_ptrs[*s]];
|
||||||
if(cWidth>lWidth)
|
if(cWidth>lWidth)
|
||||||
lWidth = cWidth;
|
lWidth = cWidth;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef GRAPHICS_H
|
#ifndef GRAPHICS_H
|
||||||
#define GRAPHICS_H
|
#define GRAPHICS_H
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -116,15 +116,15 @@ public:
|
|||||||
static pixel *render_packed_rgb(void *image, int width, int height, int cmp_size);
|
static pixel *render_packed_rgb(void *image, int width, int height, int cmp_size);
|
||||||
|
|
||||||
//Font/text metrics
|
//Font/text metrics
|
||||||
static int CharIndexAtPosition(char *s, int positionX, int positionY);
|
static int CharIndexAtPosition(String s, int positionX, int positionY);
|
||||||
static int PositionAtCharIndex(char *s, int charIndex, int & positionX, int & positionY);
|
static int PositionAtCharIndex(String s, int charIndex, int & positionX, int & positionY);
|
||||||
static int CharWidth(unsigned char c);
|
static int CharWidth(String::value_type c);
|
||||||
static int textnwidth(char *s, int n);
|
static int textnwidth(String s, int n);
|
||||||
static void textnpos(char *s, int n, int w, int *cx, int *cy);
|
static void textnpos(String s, int n, int w, int *cx, int *cy);
|
||||||
static int textwidthx(char *s, int w);
|
static int textwidthx(String s, int w);
|
||||||
static int textwrapheight(char *s, int width);
|
static int textwrapheight(String s, int width);
|
||||||
static int textwidth(const char *s);
|
static int textwidth(String s);
|
||||||
static void textsize(const char * s, int & width, int & height);
|
static void textsize(String s, int & width, int & height);
|
||||||
|
|
||||||
VideoBuffer DumpFrame();
|
VideoBuffer DumpFrame();
|
||||||
|
|
||||||
@ -139,11 +139,10 @@ public:
|
|||||||
void Clear();
|
void Clear();
|
||||||
void Finalise();
|
void Finalise();
|
||||||
//
|
//
|
||||||
int drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a);
|
int drawtext_outline(int x, int y, String s, int r, int g, int b, int a);
|
||||||
int drawtext(int x, int y, const char *s, int r, int g, int b, int a);
|
int drawtext(int x, int y, String s, int r, int g, int b, int a);
|
||||||
int drawtext(int x, int y, std::string s, int r, int g, int b, int a);
|
int drawchar(int x, int y, String::value_type c, int r, int g, int b, int a);
|
||||||
int drawchar(int x, int y, int c, int r, int g, int b, int a);
|
int addchar(int x, int y, String::value_type c, int r, int g, int b, int a);
|
||||||
int addchar(int x, int y, int c, int r, int g, int b, int a);
|
|
||||||
|
|
||||||
void xor_pixel(int x, int y);
|
void xor_pixel(int x, int y);
|
||||||
void xor_line(int x, int y, int x2, int y2);
|
void xor_line(int x, int y, int x2, int y2);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "../data/font.h"
|
#include "../data/font.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a)
|
int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, String s, int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
drawtext(x-1, y-1, s, 0, 0, 0, 120);
|
drawtext(x-1, y-1, s, 0, 0, 0, 120);
|
||||||
drawtext(x+1, y+1, s, 0, 0, 0, 120);
|
drawtext(x+1, y+1, s, 0, 0, 0, 120);
|
||||||
@ -12,7 +12,7 @@ int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int
|
|||||||
return drawtext(x, y, s, r, g, b, a);
|
return drawtext(x, y, s, r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int b, int a)
|
int PIXELMETHODS_CLASS::drawtext(int x, int y, String str, int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
bool invert = false;
|
bool invert = false;
|
||||||
if(!strlen(s))
|
if(!strlen(s))
|
||||||
@ -23,6 +23,7 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int
|
|||||||
VideoBuffer texture(width, height);
|
VideoBuffer texture(width, height);
|
||||||
int characterX = 0, characterY = 0;
|
int characterX = 0, characterY = 0;
|
||||||
int startX = characterX;
|
int startX = characterX;
|
||||||
|
String::value_type *s = str.c_str();
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
if (*s == '\n')
|
if (*s == '\n')
|
||||||
@ -98,7 +99,7 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
characterX = texture.SetCharacter(characterX, characterY, *(unsigned char *)s, r, g, b, a);
|
characterX = texture.SetCharacter(characterX, characterY, *s, r, g, b, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
@ -128,12 +129,7 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PIXELMETHODS_CLASS::drawtext(int x, int y, std::string s, int r, int g, int b, int a)
|
int PIXELMETHODS_CLASS::drawchar(int x, int y, String::value_type c, int r, int g, int b, int a)
|
||||||
{
|
|
||||||
return drawtext(x, y, s.c_str(), r, g, b, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a)
|
|
||||||
{
|
{
|
||||||
unsigned char *rp = font_data + font_ptrs[c];
|
unsigned char *rp = font_data + font_ptrs[c];
|
||||||
int w = *(rp++);
|
int w = *(rp++);
|
||||||
@ -162,7 +158,7 @@ int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a
|
|||||||
return x + w;
|
return x + w;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a)
|
int PIXELMETHODS_CLASS::addchar(int x, int y, String::value_type c, int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
unsigned char *rp = font_data + font_ptrs[c];
|
unsigned char *rp = font_data + font_ptrs[c];
|
||||||
int w = *(rp++);
|
int w = *(rp++);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a)
|
int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, String s, int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
drawtext(x-1, y-1, s, 0, 0, 0, 120);
|
drawtext(x-1, y-1, s, 0, 0, 0, 120);
|
||||||
drawtext(x+1, y+1, s, 0, 0, 0, 120);
|
drawtext(x+1, y+1, s, 0, 0, 0, 120);
|
||||||
@ -12,15 +12,16 @@ int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int
|
|||||||
return drawtext(x, y, s, r, g, b, a);
|
return drawtext(x, y, s, r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int b, int a)
|
int PIXELMETHODS_CLASS::drawtext(int x, int y, String str, int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
if(!strlen(s))
|
if(!str.size())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int invert = 0;
|
int invert = 0;
|
||||||
int oR = r, oG = g, oB = b;
|
int oR = r, oG = g, oB = b;
|
||||||
int characterX = x, characterY = y;
|
int characterX = x, characterY = y;
|
||||||
int startX = characterX;
|
int startX = characterX;
|
||||||
|
String::value_type const *s = str.c_str();
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
if (*s == '\n')
|
if (*s == '\n')
|
||||||
@ -96,18 +97,13 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
characterX = drawchar(characterX, characterY, *(unsigned char *)s, r, g, b, a);
|
characterX = drawchar(characterX, characterY, *s, r, g, b, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PIXELMETHODS_CLASS::drawtext(int x, int y, std::string s, int r, int g, int b, int a)
|
int PIXELMETHODS_CLASS::drawchar(int x, int y, String::value_type c, int r, int g, int b, int a)
|
||||||
{
|
|
||||||
return drawtext(x, y, s.c_str(), r, g, b, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a)
|
|
||||||
{
|
{
|
||||||
int i, j, w, bn = 0, ba = 0;
|
int i, j, w, bn = 0, ba = 0;
|
||||||
unsigned char *rp = font_data + font_ptrs[c];
|
unsigned char *rp = font_data + font_ptrs[c];
|
||||||
@ -127,7 +123,7 @@ int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a
|
|||||||
return x + w;
|
return x + w;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a)
|
int PIXELMETHODS_CLASS::addchar(int x, int y, String::value_type c, int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
int i, j, w, bn = 0, ba = 0;
|
int i, j, w, bn = 0, ba = 0;
|
||||||
unsigned char *rp = font_data + font_ptrs[c];
|
unsigned char *rp = font_data + font_ptrs[c];
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -519,17 +520,16 @@ void Renderer::RenderZoom()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int Renderer_wtypesCount;
|
std::vector<wall_type> Renderer_wtypes = LoadWalls();
|
||||||
wall_type * Renderer_wtypes = LoadWalls(Renderer_wtypesCount);
|
|
||||||
|
|
||||||
|
|
||||||
VideoBuffer * Renderer::WallIcon(int wallID, int width, int height)
|
VideoBuffer * Renderer::WallIcon(int wallID, int width, int height)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int wt = wallID;
|
int wt = wallID;
|
||||||
if (wt<0 || wt>=Renderer_wtypesCount)
|
if (wt<0 || wt>=(int)Renderer_wtypes.size())
|
||||||
return 0;
|
return 0;
|
||||||
wall_type *wtypes = Renderer_wtypes;
|
wall_type *wtypes = Renderer_wtypes.data();
|
||||||
pixel pc = wtypes[wt].colour;
|
pixel pc = wtypes[wt].colour;
|
||||||
pixel gc = wtypes[wt].eglow;
|
pixel gc = wtypes[wt].eglow;
|
||||||
VideoBuffer * newTexture = new VideoBuffer(width, height);
|
VideoBuffer * newTexture = new VideoBuffer(width, height);
|
||||||
@ -985,8 +985,8 @@ void Renderer::DrawSigns()
|
|||||||
for (size_t i = 0; i < signs.size(); i++)
|
for (size_t i = 0; i < signs.size(); i++)
|
||||||
if (signs[i].text.length())
|
if (signs[i].text.length())
|
||||||
{
|
{
|
||||||
char type = 0;
|
String::value_type type = 0;
|
||||||
std::string text = signs[i].getText(sim);
|
String text = signs[i].getText(sim);
|
||||||
sign::splitsign(signs[i].text, &type);
|
sign::splitsign(signs[i].text, &type);
|
||||||
signs[i].pos(text, x, y, w, h);
|
signs[i].pos(text, x, y, w, h);
|
||||||
clearrect(x, y, w+1, h);
|
clearrect(x, y, w+1, h);
|
||||||
@ -1496,9 +1496,9 @@ void Renderer::render_parts()
|
|||||||
|
|
||||||
if (mousePos.X>(nx-3) && mousePos.X<(nx+3) && mousePos.Y<(ny+3) && mousePos.Y>(ny-3)) //If mouse is in the head
|
if (mousePos.X>(nx-3) && mousePos.X<(nx+3) && mousePos.Y<(ny+3) && mousePos.Y>(ny-3)) //If mouse is in the head
|
||||||
{
|
{
|
||||||
char buff[12]; //Buffer for HP
|
String::Stream hp;
|
||||||
sprintf(buff, "%3d", sim->parts[i].life); //Show HP
|
hp << std::setw(3) << sim->parts[i].life;
|
||||||
drawtext(mousePos.X-8-2*(sim->parts[i].life<100)-2*(sim->parts[i].life<10), mousePos.Y-12, buff, 255, 255, 255, 255);
|
drawtext(mousePos.X-8-2*(sim->parts[i].life<100)-2*(sim->parts[i].life<10), mousePos.Y-12, hp.str(), 255, 255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (findingElement == t)
|
if (findingElement == t)
|
||||||
|
@ -113,11 +113,10 @@ public:
|
|||||||
|
|
||||||
void draw_icon(int x, int y, Icon icon);
|
void draw_icon(int x, int y, Icon icon);
|
||||||
|
|
||||||
int drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a);
|
int drawtext_outline(int x, int y, String s, int r, int g, int b, int a);
|
||||||
int drawtext(int x, int y, const char *s, int r, int g, int b, int a);
|
int drawtext(int x, int y, String s, int r, int g, int b, int a);
|
||||||
int drawtext(int x, int y, std::string s, int r, int g, int b, int a);
|
int drawchar(int x, int y, String::value_type c, int r, int g, int b, int a);
|
||||||
int drawchar(int x, int y, int c, int r, int g, int b, int a);
|
int addchar(int x, int y, String::value_type c, int r, int g, int b, int a);
|
||||||
int addchar(int x, int y, int c, int r, int g, int b, int a);
|
|
||||||
|
|
||||||
void xor_pixel(int x, int y);
|
void xor_pixel(int x, int y);
|
||||||
void xor_line(int x, int y, int x2, int y2);
|
void xor_line(int x, int y, int x2, int y2);
|
||||||
|
@ -108,8 +108,8 @@ void ColourPickerActivity::UpdateTextboxes(int r, int g, int b, int a)
|
|||||||
gValue->SetText(format::NumberToString<int>(g));
|
gValue->SetText(format::NumberToString<int>(g));
|
||||||
bValue->SetText(format::NumberToString<int>(b));
|
bValue->SetText(format::NumberToString<int>(b));
|
||||||
aValue->SetText(format::NumberToString<int>(a));
|
aValue->SetText(format::NumberToString<int>(a));
|
||||||
std::stringstream hex;
|
String::Stream hex;
|
||||||
hex << std::hex << "0x" << std::setfill('0') << std::setw(2) << std::uppercase << a << std::setw(2) << r << std::setw(2) << g << std::setw(2) << b;
|
hex << std::hex << "0x" << std::setfill(String::value_type('0')) << std::setw(2) << std::uppercase << a << std::setw(2) << r << std::setw(2) << g << std::setw(2) << b;
|
||||||
hexValue->SetText(hex.str());
|
hexValue->SetText(hex.str());
|
||||||
}
|
}
|
||||||
void ColourPickerActivity::OnTryExit(ExitMethod method)
|
void ColourPickerActivity::OnTryExit(ExitMethod method)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "Activity.h"
|
#include "Activity.h"
|
||||||
#include "gui/interface/Window.h"
|
#include "gui/interface/Window.h"
|
||||||
#include "gui/interface/Textbox.h"
|
#include "gui/interface/Textbox.h"
|
||||||
|
@ -4,18 +4,18 @@
|
|||||||
class ConsoleCommand
|
class ConsoleCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConsoleCommand(std::string command, int returnStatus, std::string returnValue):
|
ConsoleCommand(String command, int returnStatus, String returnValue):
|
||||||
Command(command), ReturnStatus(returnStatus), ReturnValue(returnValue)
|
Command(command), ReturnStatus(returnStatus), ReturnValue(returnValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
std::string Command;
|
String Command;
|
||||||
int ReturnStatus;
|
int ReturnStatus;
|
||||||
std::string ReturnValue;
|
String ReturnValue;
|
||||||
|
|
||||||
operator std::string() const
|
operator ByteString() const
|
||||||
{
|
{
|
||||||
return Command;
|
return Command.ToUtf8();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ ConsoleController::ConsoleController(ControllerCallback * callback, CommandInter
|
|||||||
this->commandInterface = commandInterface;
|
this->commandInterface = commandInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleController::EvaluateCommand(std::string command)
|
void ConsoleController::EvaluateCommand(String command)
|
||||||
{
|
{
|
||||||
if(command.length())
|
if(command.length())
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ void ConsoleController::CloseConsole()
|
|||||||
consoleView->CloseActiveWindow();
|
consoleView->CloseActiveWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ConsoleController::FormatCommand(std::string command)
|
String ConsoleController::FormatCommand(String command)
|
||||||
{
|
{
|
||||||
return commandInterface->FormatCommand(command);
|
return commandInterface->FormatCommand(command);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef CONSOLECONTROLLER_H_
|
#ifndef CONSOLECONTROLLER_H_
|
||||||
#define CONSOLECONTROLLER_H_
|
#define CONSOLECONTROLLER_H_
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
#include "ConsoleView.h"
|
#include "ConsoleView.h"
|
||||||
#include "ConsoleModel.h"
|
#include "ConsoleModel.h"
|
||||||
@ -18,8 +18,8 @@ class ConsoleController {
|
|||||||
public:
|
public:
|
||||||
bool HasDone;
|
bool HasDone;
|
||||||
ConsoleController(ControllerCallback * callback, CommandInterface * commandInterface);
|
ConsoleController(ControllerCallback * callback, CommandInterface * commandInterface);
|
||||||
std::string FormatCommand(std::string command);
|
String FormatCommand(String command);
|
||||||
void EvaluateCommand(std::string command);
|
void EvaluateCommand(String command);
|
||||||
void NextCommand();
|
void NextCommand();
|
||||||
void PreviousCommand();
|
void PreviousCommand();
|
||||||
void Exit();
|
void Exit();
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
#include "ConsoleModel.h"
|
#include "ConsoleModel.h"
|
||||||
|
|
||||||
ConsoleModel::ConsoleModel() {
|
ConsoleModel::ConsoleModel() {
|
||||||
std::vector<std::string> previousHistory = Client::Ref().GetPrefStringArray("Console.History");
|
std::vector<String> previousHistory = Client::Ref().GetPrefStringArray("Console.History");
|
||||||
for(std::vector<std::string>::reverse_iterator iter = previousHistory.rbegin(), end = previousHistory.rend(); iter != end; ++iter)
|
for(std::vector<String>::reverse_iterator iter = previousHistory.rbegin(), end = previousHistory.rend(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
if(previousCommands.size()<25)
|
if(previousCommands.size()<25)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "gui/interface/ScrollPanel.h"
|
#include "gui/interface/ScrollPanel.h"
|
||||||
#include "PowderToy.h"
|
#include "PowderToy.h"
|
||||||
|
|
||||||
ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDialogueCallback * callback_):
|
ConfirmPrompt::ConfirmPrompt(String title, String message, ConfirmDialogueCallback * callback_):
|
||||||
ui::Window(ui::Point(-1, -1), ui::Point(250, 35)),
|
ui::Window(ui::Point(-1, -1), ui::Point(250, 35)),
|
||||||
callback(callback_)
|
callback(callback_)
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDial
|
|||||||
MakeActiveWindow();
|
MakeActiveWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, std::string buttonText, ConfirmDialogueCallback * callback_):
|
ConfirmPrompt::ConfirmPrompt(String title, String message, String buttonText, ConfirmDialogueCallback * callback_):
|
||||||
ui::Window(ui::Point(-1, -1), ui::Point(250, 50)),
|
ui::Window(ui::Point(-1, -1), ui::Point(250, 50)),
|
||||||
callback(callback_)
|
callback(callback_)
|
||||||
{
|
{
|
||||||
@ -130,7 +130,7 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, std::string
|
|||||||
MakeActiveWindow();
|
MakeActiveWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfirmPrompt::Blocking(std::string title, std::string message, std::string buttonText)
|
bool ConfirmPrompt::Blocking(String title, String message, String buttonText)
|
||||||
{
|
{
|
||||||
class BlockingPromptCallback: public ConfirmDialogueCallback {
|
class BlockingPromptCallback: public ConfirmDialogueCallback {
|
||||||
public:
|
public:
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
#ifndef CONFIRMPROMPT_H_
|
#ifndef CONFIRMPROMPT_H_
|
||||||
#define CONFIRMPROMPT_H_
|
#define CONFIRMPROMPT_H_
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "gui/interface/Window.h"
|
#include "gui/interface/Window.h"
|
||||||
|
|
||||||
class ConfirmDialogueCallback;
|
class ConfirmDialogueCallback;
|
||||||
class ConfirmPrompt: public ui::Window {
|
class ConfirmPrompt: public ui::Window {
|
||||||
public:
|
public:
|
||||||
enum DialogueResult { ResultCancel, ResultOkay };
|
enum DialogueResult { ResultCancel, ResultOkay };
|
||||||
ConfirmPrompt(std::string title, std::string message, ConfirmDialogueCallback * callback_ = NULL);
|
ConfirmPrompt(String title, String message, ConfirmDialogueCallback * callback_ = NULL);
|
||||||
ConfirmPrompt(std::string title, std::string message, std::string buttonText, ConfirmDialogueCallback * callback_ = NULL);
|
ConfirmPrompt(String title, String message, String buttonText, ConfirmDialogueCallback * callback_ = NULL);
|
||||||
static bool Blocking(std::string title, std::string message, std::string buttonText = "Confirm");
|
static bool Blocking(String title, String message, String buttonText = "Confirm");
|
||||||
virtual void OnDraw();
|
virtual void OnDraw();
|
||||||
virtual ~ConfirmPrompt();
|
virtual ~ConfirmPrompt();
|
||||||
ConfirmDialogueCallback * callback;
|
ConfirmDialogueCallback * callback;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "gui/interface/Label.h"
|
#include "gui/interface/Label.h"
|
||||||
#include "PowderToy.h"
|
#include "PowderToy.h"
|
||||||
|
|
||||||
ErrorMessage::ErrorMessage(std::string title, std::string message, ErrorMessageCallback * callback_):
|
ErrorMessage::ErrorMessage(String title, String message, ErrorMessageCallback * callback_):
|
||||||
ui::Window(ui::Point(-1, -1), ui::Point(200, 35)),
|
ui::Window(ui::Point(-1, -1), ui::Point(200, 35)),
|
||||||
callback(callback_)
|
callback(callback_)
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ ErrorMessage::ErrorMessage(std::string title, std::string message, ErrorMessage
|
|||||||
MakeActiveWindow();
|
MakeActiveWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorMessage::Blocking(std::string title, std::string message)
|
void ErrorMessage::Blocking(String title, String message)
|
||||||
{
|
{
|
||||||
class BlockingDismissCallback: public ErrorMessageCallback {
|
class BlockingDismissCallback: public ErrorMessageCallback {
|
||||||
public:
|
public:
|
||||||
|
@ -7,8 +7,8 @@ class ErrorMessageCallback;
|
|||||||
class ErrorMessage: public ui::Window {
|
class ErrorMessage: public ui::Window {
|
||||||
ErrorMessageCallback * callback;
|
ErrorMessageCallback * callback;
|
||||||
public:
|
public:
|
||||||
ErrorMessage(std::string title, std::string message, ErrorMessageCallback * callback_ = NULL);
|
ErrorMessage(String title, String message, ErrorMessageCallback * callback_ = NULL);
|
||||||
static void Blocking(std::string title, std::string message);
|
static void Blocking(String title, String message);
|
||||||
virtual void OnDraw();
|
virtual void OnDraw();
|
||||||
virtual ~ErrorMessage();
|
virtual ~ErrorMessage();
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "gui/interface/Label.h"
|
#include "gui/interface/Label.h"
|
||||||
#include "gui/interface/ScrollPanel.h"
|
#include "gui/interface/ScrollPanel.h"
|
||||||
|
|
||||||
InformationMessage::InformationMessage(std::string title, std::string message, bool large):
|
InformationMessage::InformationMessage(String title, String message, bool large):
|
||||||
ui::Window(ui::Point(-1, -1), ui::Point(200, 35))
|
ui::Window(ui::Point(-1, -1), ui::Point(200, 35))
|
||||||
{
|
{
|
||||||
if (large) //Maybe also use this large mode for changelogs eventually, or have it as a customizable size?
|
if (large) //Maybe also use this large mode for changelogs eventually, or have it as a customizable size?
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class InformationMessage: public ui::Window {
|
class InformationMessage: public ui::Window {
|
||||||
public:
|
public:
|
||||||
InformationMessage(std::string title, std::string message, bool large);
|
InformationMessage(String title, String message, bool large);
|
||||||
virtual void OnDraw();
|
virtual void OnDraw();
|
||||||
virtual ~InformationMessage();
|
virtual ~InformationMessage();
|
||||||
};
|
};
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
//Legacy blocking prompts
|
//Legacy blocking prompts
|
||||||
//This are not implemented here, but rather in the engine bootstrapper
|
//This are not implemented here, but rather in the engine bootstrapper
|
||||||
bool ConfirmUI(std::string title, std::string message, std::string confirmText) {}
|
bool ConfirmUI(String title, String message, String confirmText) {}
|
||||||
|
|
||||||
void ErrorUI(std::string title, std::string message) {}
|
void ErrorUI(String title, String message) {}
|
||||||
|
|
||||||
void InformationUI(std::string title, std::string message) {}
|
void InformationUI(String title, String message) {}
|
||||||
|
|
||||||
std::string MessagePromptUI(std::string title, std::string message, std::string text, std::string placeholder) {}
|
String MessagePromptUI(String title, String message, String text, String placeholder) {}
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TextPrompt::TextPrompt(std::string title, std::string message, std::string text, std::string placeholder, bool multiline, TextDialogueCallback * callback_):
|
TextPrompt::TextPrompt(String title, String message, String text, String placeholder, bool multiline, TextDialogueCallback * callback_):
|
||||||
ui::Window(ui::Point(-1, -1), ui::Point(200, 65)),
|
ui::Window(ui::Point(-1, -1), ui::Point(200, 65)),
|
||||||
callback(callback_)
|
callback(callback_)
|
||||||
{
|
{
|
||||||
@ -77,15 +77,15 @@ TextPrompt::TextPrompt(std::string title, std::string message, std::string text,
|
|||||||
MakeActiveWindow();
|
MakeActiveWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TextPrompt::Blocking(std::string title, std::string message, std::string text, std::string placeholder, bool multiline)
|
String TextPrompt::Blocking(String title, String message, String text, String placeholder, bool multiline)
|
||||||
{
|
{
|
||||||
std::string returnString = "";
|
String returnString = "";
|
||||||
|
|
||||||
class BlockingTextCallback: public TextDialogueCallback {
|
class BlockingTextCallback: public TextDialogueCallback {
|
||||||
std::string & outputString;
|
String & outputString;
|
||||||
public:
|
public:
|
||||||
BlockingTextCallback(std::string & output) : outputString(output) {}
|
BlockingTextCallback(String & output) : outputString(output) {}
|
||||||
virtual void TextCallback(TextPrompt::DialogueResult result, std::string resultText) {
|
virtual void TextCallback(TextPrompt::DialogueResult result, String resultText) {
|
||||||
if(result == ResultOkay)
|
if(result == ResultOkay)
|
||||||
outputString = resultText;
|
outputString = resultText;
|
||||||
else
|
else
|
||||||
|
@ -11,8 +11,8 @@ protected:
|
|||||||
public:
|
public:
|
||||||
friend class CloseAction;
|
friend class CloseAction;
|
||||||
enum DialogueResult { ResultCancel, ResultOkay };
|
enum DialogueResult { ResultCancel, ResultOkay };
|
||||||
TextPrompt(std::string title, std::string message, std::string text, std::string placeholder, bool multiline, TextDialogueCallback * callback_);
|
TextPrompt(String title, String message, String text, String placeholder, bool multiline, TextDialogueCallback * callback_);
|
||||||
static std::string Blocking(std::string title, std::string message, std::string text, std::string placeholder, bool multiline);
|
static String Blocking(String title, String message, String text, String placeholder, bool multiline);
|
||||||
virtual void OnDraw();
|
virtual void OnDraw();
|
||||||
virtual ~TextPrompt();
|
virtual ~TextPrompt();
|
||||||
TextDialogueCallback * callback;
|
TextDialogueCallback * callback;
|
||||||
@ -21,7 +21,7 @@ public:
|
|||||||
class TextDialogueCallback
|
class TextDialogueCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void TextCallback(TextPrompt::DialogueResult result, std::string resultText) {}
|
virtual void TextCallback(TextPrompt::DialogueResult result, String resultText) {}
|
||||||
virtual ~TextDialogueCallback() {}
|
virtual ~TextDialogueCallback() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include "common/String.h"
|
||||||
#include "ElementSearchActivity.h"
|
#include "ElementSearchActivity.h"
|
||||||
#include "gui/interface/Textbox.h"
|
#include "gui/interface/Textbox.h"
|
||||||
#include "gui/interface/Label.h"
|
#include "gui/interface/Label.h"
|
||||||
@ -91,7 +92,7 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st
|
|||||||
searchTools("");
|
searchTools("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementSearchActivity::searchTools(std::string query)
|
void ElementSearchActivity::searchTools(String query)
|
||||||
{
|
{
|
||||||
firstResult = NULL;
|
firstResult = NULL;
|
||||||
for(std::vector<ToolButton*>::iterator iter = toolButtons.begin(), end = toolButtons.end(); iter != end; ++iter) {
|
for(std::vector<ToolButton*>::iterator iter = toolButtons.begin(), end = toolButtons.end(); iter != end; ++iter) {
|
||||||
@ -103,7 +104,7 @@ void ElementSearchActivity::searchTools(std::string query)
|
|||||||
ui::Point viewPosition = searchField->Position + ui::Point(2+0, searchField->Size.Y+2+8);
|
ui::Point viewPosition = searchField->Position + ui::Point(2+0, searchField->Size.Y+2+8);
|
||||||
ui::Point current = ui::Point(0, 0);
|
ui::Point current = ui::Point(0, 0);
|
||||||
|
|
||||||
std::string queryLower = std::string(query);
|
ByteString queryLower = query.ToAscii();
|
||||||
std::transform(queryLower.begin(), queryLower.end(), queryLower.begin(), ::tolower);
|
std::transform(queryLower.begin(), queryLower.end(), queryLower.begin(), ::tolower);
|
||||||
|
|
||||||
std::vector<Tool *> matches;
|
std::vector<Tool *> matches;
|
||||||
@ -112,13 +113,13 @@ void ElementSearchActivity::searchTools(std::string query)
|
|||||||
|
|
||||||
for(std::vector<Tool*>::const_iterator iter = tools.begin(), end = tools.end(); iter != end; ++iter)
|
for(std::vector<Tool*>::const_iterator iter = tools.begin(), end = tools.end(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
std::string nameLower = std::string((*iter)->GetName());
|
ByteString nameLower = (*iter)->GetName();
|
||||||
std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), ::tolower);
|
std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), ::tolower);
|
||||||
if(!strcmp(nameLower.c_str(), queryLower.c_str()))
|
if(nameLower == queryLower)
|
||||||
exactmatches.push_back(*iter);
|
exactmatches.push_back(*iter);
|
||||||
else if(!strncmp(nameLower.c_str(), queryLower.c_str(), queryLower.length()))
|
else if(!nameLower.compare(0, queryLower.length(), queryLower))
|
||||||
frontmatches.push_back(*iter);
|
frontmatches.push_back(*iter);
|
||||||
else if(strstr(nameLower.c_str(), queryLower.c_str()))
|
else if(nameLower.find(queryLower) != String::npos)
|
||||||
matches.push_back(*iter);
|
matches.push_back(*iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +199,7 @@ void ElementSearchActivity::OnDraw()
|
|||||||
g->drawrect(Position.X+searchField->Position.X, Position.Y+searchField->Position.Y+searchField->Size.Y+8, searchField->Size.X, Size.Y-(searchField->Position.Y+searchField->Size.Y+8)-23, 255, 255, 255, 180);
|
g->drawrect(Position.X+searchField->Position.X, Position.Y+searchField->Position.Y+searchField->Size.Y+8, searchField->Size.X, Size.Y-(searchField->Position.Y+searchField->Size.Y+8)-23, 255, 255, 255, 180);
|
||||||
if (toolTipPresence && toolTip.length())
|
if (toolTipPresence && toolTip.length())
|
||||||
{
|
{
|
||||||
g->drawtext(10, Size.Y+70, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
|
g->drawtext(10, Size.Y+70, toolTip, 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +266,7 @@ void ElementSearchActivity::OnKeyRelease(int key, Uint16 character, bool shift,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementSearchActivity::ToolTip(ui::Point senderPosition, std::string toolTip)
|
void ElementSearchActivity::ToolTip(ui::Point senderPosition, String toolTip)
|
||||||
{
|
{
|
||||||
this->toolTip = toolTip;
|
this->toolTip = toolTip;
|
||||||
this->isToolTipFadingIn = true;
|
this->isToolTipFadingIn = true;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define ELEMENTSEARCHACTIVITY_H_
|
#define ELEMENTSEARCHACTIVITY_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
|
||||||
#include "Activity.h"
|
#include "Activity.h"
|
||||||
#include "gui/interface/Window.h"
|
#include "gui/interface/Window.h"
|
||||||
#include "gui/interface/Textbox.h"
|
#include "gui/interface/Textbox.h"
|
||||||
@ -18,13 +17,13 @@ class ElementSearchActivity: public WindowActivity
|
|||||||
std::vector<Tool*> tools;
|
std::vector<Tool*> tools;
|
||||||
ui::Textbox * searchField;
|
ui::Textbox * searchField;
|
||||||
std::vector<ToolButton*> toolButtons;
|
std::vector<ToolButton*> toolButtons;
|
||||||
std::string toolTip;
|
String toolTip;
|
||||||
int toolTipPresence;
|
int toolTipPresence;
|
||||||
bool shiftPressed;
|
bool shiftPressed;
|
||||||
bool ctrlPressed;
|
bool ctrlPressed;
|
||||||
bool altPressed;
|
bool altPressed;
|
||||||
bool isToolTipFadingIn;
|
bool isToolTipFadingIn;
|
||||||
void searchTools(std::string query);
|
void searchTools(String query);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class ToolAction;
|
class ToolAction;
|
||||||
@ -37,7 +36,7 @@ public:
|
|||||||
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||||
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||||
virtual void OnDraw();
|
virtual void OnDraw();
|
||||||
virtual void ToolTip(ui::Point senderPosition, std::string ToolTip);
|
virtual void ToolTip(ui::Point senderPosition, String ToolTip);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* ELEMENTSEARCHACTIVITY_H_ */
|
#endif /* ELEMENTSEARCHACTIVITY_H_ */
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <sstream>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "FileBrowserActivity.h"
|
#include "FileBrowserActivity.h"
|
||||||
@ -42,8 +41,8 @@ public:
|
|||||||
//Currently, reading is done on another thread, we can't render outside the main thread due to some bullshit with OpenGL
|
//Currently, reading is done on another thread, we can't render outside the main thread due to some bullshit with OpenGL
|
||||||
class LoadFilesTask: public Task
|
class LoadFilesTask: public Task
|
||||||
{
|
{
|
||||||
std::string directory;
|
ByteString directory;
|
||||||
std::string search;
|
ByteString search;
|
||||||
std::vector<SaveFile*> saveFiles;
|
std::vector<SaveFile*> saveFiles;
|
||||||
|
|
||||||
virtual void before()
|
virtual void before()
|
||||||
@ -58,15 +57,15 @@ class LoadFilesTask: public Task
|
|||||||
|
|
||||||
virtual bool doWork()
|
virtual bool doWork()
|
||||||
{
|
{
|
||||||
std::vector<std::string> files = Client::Ref().DirectorySearch(directory, search, ".cps");
|
std::vector<ByteString> files = Client::Ref().DirectorySearch(directory, search, ".cps");
|
||||||
std::sort(files.rbegin(), files.rend(), [](std::string a, std::string b) {
|
std::sort(files.rbegin(), files.rend(), [](ByteString a, ByteString b) {
|
||||||
std::transform(a.begin(), a.end(), a.begin(), ::tolower);
|
std::transform(a.begin(), a.end(), a.begin(), ::tolower);
|
||||||
std::transform(b.begin(), b.end(), b.begin(), ::tolower);
|
std::transform(b.begin(), b.end(), b.begin(), ::tolower);
|
||||||
return a < b;
|
return a < b;
|
||||||
});
|
});
|
||||||
|
|
||||||
notifyProgress(-1);
|
notifyProgress(-1);
|
||||||
for(std::vector<std::string>::iterator iter = files.begin(), end = files.end(); iter != end; ++iter)
|
for(std::vector<ByteString>::iterator iter = files.begin(), end = files.end(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
SaveFile * saveFile = new SaveFile(*iter);
|
SaveFile * saveFile = new SaveFile(*iter);
|
||||||
try
|
try
|
||||||
@ -76,18 +75,18 @@ class LoadFilesTask: public Task
|
|||||||
saveFile->SetGameSave(tempSave);
|
saveFile->SetGameSave(tempSave);
|
||||||
saveFiles.push_back(saveFile);
|
saveFiles.push_back(saveFile);
|
||||||
|
|
||||||
std::string filename = *iter;
|
ByteString filename = *iter;
|
||||||
size_t folderPos = filename.rfind(PATH_SEP);
|
size_t folderPos = filename.rfind(PATH_SEP);
|
||||||
if(folderPos!=std::string::npos && folderPos+1 < filename.size())
|
if(folderPos!=ByteString::npos && folderPos+1 < filename.size())
|
||||||
{
|
{
|
||||||
filename = filename.substr(folderPos+1);
|
filename = filename.substr(folderPos+1);
|
||||||
}
|
}
|
||||||
size_t extPos = filename.rfind(".");
|
size_t extPos = filename.rfind(".");
|
||||||
if(extPos!=std::string::npos)
|
if(extPos!=ByteString::npos)
|
||||||
{
|
{
|
||||||
filename = filename.substr(0, extPos);
|
filename = filename.substr(0, extPos);
|
||||||
}
|
}
|
||||||
saveFile->SetDisplayName(filename);
|
saveFile->SetDisplayName(filename.FromUtf8());
|
||||||
}
|
}
|
||||||
catch(std::exception & e)
|
catch(std::exception & e)
|
||||||
{
|
{
|
||||||
@ -103,7 +102,7 @@ public:
|
|||||||
return saveFiles;
|
return saveFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadFilesTask(std::string directory, std::string search):
|
LoadFilesTask(ByteString directory, ByteString search):
|
||||||
directory(directory),
|
directory(directory),
|
||||||
search(search)
|
search(search)
|
||||||
{
|
{
|
||||||
@ -117,11 +116,11 @@ public:
|
|||||||
FileBrowserActivity * a;
|
FileBrowserActivity * a;
|
||||||
SearchAction(FileBrowserActivity * a) : a(a) {}
|
SearchAction(FileBrowserActivity * a) : a(a) {}
|
||||||
virtual void TextChangedCallback(ui::Textbox * sender) {
|
virtual void TextChangedCallback(ui::Textbox * sender) {
|
||||||
a->DoSearch(sender->GetText());
|
a->DoSearch(sender->GetText().ToUtf8());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
FileBrowserActivity::FileBrowserActivity(std::string directory, FileSelectedCallback * callback):
|
FileBrowserActivity::FileBrowserActivity(ByteString directory, FileSelectedCallback * callback):
|
||||||
WindowActivity(ui::Point(-1, -1), ui::Point(450, 300)),
|
WindowActivity(ui::Point(-1, -1), ui::Point(450, 300)),
|
||||||
callback(callback),
|
callback(callback),
|
||||||
directory(directory),
|
directory(directory),
|
||||||
@ -167,7 +166,7 @@ FileBrowserActivity::FileBrowserActivity(std::string directory, FileSelectedCall
|
|||||||
loadDirectory(directory, "");
|
loadDirectory(directory, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowserActivity::DoSearch(std::string search)
|
void FileBrowserActivity::DoSearch(ByteString search)
|
||||||
{
|
{
|
||||||
if(!loadFiles)
|
if(!loadFiles)
|
||||||
{
|
{
|
||||||
@ -184,7 +183,7 @@ void FileBrowserActivity::SelectSave(SaveFile * file)
|
|||||||
|
|
||||||
void FileBrowserActivity::DeleteSave(SaveFile * file)
|
void FileBrowserActivity::DeleteSave(SaveFile * file)
|
||||||
{
|
{
|
||||||
std::string deleteMessage = "Are you sure you want to delete " + file->GetDisplayName() + ".cps?";
|
String deleteMessage = "Are you sure you want to delete " + file->GetDisplayName() + ".cps?";
|
||||||
if (ConfirmPrompt::Blocking("Delete Save", deleteMessage))
|
if (ConfirmPrompt::Blocking("Delete Save", deleteMessage))
|
||||||
{
|
{
|
||||||
remove(file->GetName().c_str());
|
remove(file->GetName().c_str());
|
||||||
@ -194,7 +193,7 @@ void FileBrowserActivity::DeleteSave(SaveFile * file)
|
|||||||
|
|
||||||
void FileBrowserActivity::RenameSave(SaveFile * file)
|
void FileBrowserActivity::RenameSave(SaveFile * file)
|
||||||
{
|
{
|
||||||
std::string newName = TextPrompt::Blocking("Rename", "Change save name", file->GetDisplayName(), "", 0);
|
ByteString newName = TextPrompt::Blocking("Rename", "Change save name", file->GetDisplayName(), "", 0).ToUtf8();
|
||||||
if (newName.length())
|
if (newName.length())
|
||||||
{
|
{
|
||||||
newName = directory + PATH_SEP + newName + ".cps";
|
newName = directory + PATH_SEP + newName + ".cps";
|
||||||
@ -208,7 +207,7 @@ void FileBrowserActivity::RenameSave(SaveFile * file)
|
|||||||
ErrorMessage::Blocking("Error", "No save name given");
|
ErrorMessage::Blocking("Error", "No save name given");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowserActivity::loadDirectory(std::string directory, std::string search)
|
void FileBrowserActivity::loadDirectory(ByteString directory, ByteString search)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < components.size(); i++)
|
for (size_t i = 0; i < components.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "Activity.h"
|
#include "Activity.h"
|
||||||
#include "gui/interface/Window.h"
|
#include "gui/interface/Window.h"
|
||||||
#include "tasks/TaskListener.h"
|
#include "tasks/TaskListener.h"
|
||||||
@ -33,7 +33,7 @@ class FileBrowserActivity: public TaskListener, public WindowActivity
|
|||||||
std::vector<SaveFile*> files;
|
std::vector<SaveFile*> files;
|
||||||
std::vector<ui::Component*> components;
|
std::vector<ui::Component*> components;
|
||||||
std::vector<ui::Component*> componentsQueue;
|
std::vector<ui::Component*> componentsQueue;
|
||||||
std::string directory;
|
ByteString directory;
|
||||||
|
|
||||||
ui::ProgressBar * progressBar;
|
ui::ProgressBar * progressBar;
|
||||||
|
|
||||||
@ -46,16 +46,16 @@ class FileBrowserActivity: public TaskListener, public WindowActivity
|
|||||||
class SearchAction;
|
class SearchAction;
|
||||||
void populateList();
|
void populateList();
|
||||||
public:
|
public:
|
||||||
FileBrowserActivity(std::string directory, FileSelectedCallback * callback);
|
FileBrowserActivity(ByteString directory, FileSelectedCallback * callback);
|
||||||
virtual void OnDraw();
|
virtual void OnDraw();
|
||||||
virtual void OnTick(float dt);
|
virtual void OnTick(float dt);
|
||||||
virtual void OnTryExit(ExitMethod method);
|
virtual void OnTryExit(ExitMethod method);
|
||||||
virtual void OnMouseDown(int x, int y, unsigned button);
|
virtual void OnMouseDown(int x, int y, unsigned button);
|
||||||
void loadDirectory(std::string directory, std::string search);
|
void loadDirectory(ByteString directory, ByteString search);
|
||||||
void SelectSave(SaveFile * file);
|
void SelectSave(SaveFile * file);
|
||||||
void DeleteSave(SaveFile * file);
|
void DeleteSave(SaveFile * file);
|
||||||
void RenameSave(SaveFile * file);
|
void RenameSave(SaveFile * file);
|
||||||
void DoSearch(std::string search);
|
void DoSearch(ByteString search);
|
||||||
virtual ~FileBrowserActivity();
|
virtual ~FileBrowserActivity();
|
||||||
|
|
||||||
virtual void NotifyDone(Task * task);
|
virtual void NotifyDone(Task * task);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sstream>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@ -19,7 +18,7 @@
|
|||||||
unsigned char *font_data;
|
unsigned char *font_data;
|
||||||
short *font_ptrs;
|
short *font_ptrs;
|
||||||
|
|
||||||
void FontEditor::ReadHeader(std::string header)
|
void FontEditor::ReadHeader(ByteString header)
|
||||||
{
|
{
|
||||||
std::fstream file;
|
std::fstream file;
|
||||||
file.open(header, std::ios_base::in);
|
file.open(header, std::ios_base::in);
|
||||||
@ -27,7 +26,7 @@ void FontEditor::ReadHeader(std::string header)
|
|||||||
throw std::runtime_error("Could not open " + header);
|
throw std::runtime_error("Could not open " + header);
|
||||||
file >> std::skipws;
|
file >> std::skipws;
|
||||||
|
|
||||||
std::string word;
|
ByteString word;
|
||||||
|
|
||||||
while(word != "font_data[]")
|
while(word != "font_data[]")
|
||||||
file >> word;
|
file >> word;
|
||||||
@ -82,24 +81,24 @@ void FontEditor::ReadHeader(std::string header)
|
|||||||
size_t eof = file.tellg();
|
size_t eof = file.tellg();
|
||||||
|
|
||||||
file.seekg(0);
|
file.seekg(0);
|
||||||
beforeFontData = std::string(startFontData, 0);
|
beforeFontData = ByteString(startFontData, 0);
|
||||||
file.read(&beforeFontData[0], startFontData);
|
file.read(&beforeFontData[0], startFontData);
|
||||||
|
|
||||||
file.seekg(endFontData);
|
file.seekg(endFontData);
|
||||||
afterFontData = std::string(startFontPtrs - endFontData, 0);
|
afterFontData = ByteString(startFontPtrs - endFontData, 0);
|
||||||
file.read(&afterFontData[0], startFontPtrs - endFontData);
|
file.read(&afterFontData[0], startFontPtrs - endFontData);
|
||||||
|
|
||||||
file.seekg(endFontData);
|
file.seekg(endFontData);
|
||||||
afterFontData = std::string(startFontPtrs - endFontData, 0);
|
afterFontData = ByteString(startFontPtrs - endFontData, 0);
|
||||||
file.read(&afterFontData[0], startFontPtrs - endFontData);
|
file.read(&afterFontData[0], startFontPtrs - endFontData);
|
||||||
|
|
||||||
file.seekg(endFontPtrs);
|
file.seekg(endFontPtrs);
|
||||||
afterFontPtrs = std::string(eof - endFontPtrs, 0);
|
afterFontPtrs = ByteString(eof - endFontPtrs, 0);
|
||||||
file.read(&afterFontPtrs[0], eof - endFontPtrs);
|
file.read(&afterFontPtrs[0], eof - endFontPtrs);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontEditor::WriteHeader(std::string header, std::vector<unsigned char> const &fontData, std::vector<short> const &fontPtrs)
|
void FontEditor::WriteHeader(ByteString header, std::vector<unsigned char> const &fontData, std::vector<short> const &fontPtrs)
|
||||||
{
|
{
|
||||||
std::fstream file;
|
std::fstream file;
|
||||||
file.open(header, std::ios_base::out | std::ios_base::trunc);
|
file.open(header, std::ios_base::out | std::ios_base::trunc);
|
||||||
@ -189,7 +188,7 @@ void FontEditor::PackData(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define FONT_SCALE 16
|
#define FONT_SCALE 16
|
||||||
FontEditor::FontEditor(std::string _header):
|
FontEditor::FontEditor(ByteString _header):
|
||||||
ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, WINDOWH)),
|
ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, WINDOWH)),
|
||||||
header(_header),
|
header(_header),
|
||||||
currentChar(0x80),
|
currentChar(0x80),
|
||||||
@ -228,7 +227,7 @@ FontEditor::FontEditor(std::string _header):
|
|||||||
void TextChangedCallback(ui::Textbox *)
|
void TextChangedCallback(ui::Textbox *)
|
||||||
{
|
{
|
||||||
unsigned int number;
|
unsigned int number;
|
||||||
std::stringstream ss(v->currentCharTextbox->GetText());
|
String::Stream ss(v->currentCharTextbox->GetText());
|
||||||
ss >> std::hex >> number;
|
ss >> std::hex >> number;
|
||||||
if(number < 256)
|
if(number < 256)
|
||||||
v->currentChar = number;
|
v->currentChar = number;
|
||||||
@ -320,14 +319,14 @@ FontEditor::FontEditor(std::string _header):
|
|||||||
ColorComponentAction(int &_color): color(_color) {}
|
ColorComponentAction(int &_color): color(_color) {}
|
||||||
void TextChangedCallback(ui::Textbox *box)
|
void TextChangedCallback(ui::Textbox *box)
|
||||||
{
|
{
|
||||||
std::stringstream ss(box->GetText());
|
String::Stream ss(box->GetText());
|
||||||
ss >> color;
|
ss >> color;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
int *refs[6] = {&fgR, &fgG, &fgB, &bgR, &bgG, &bgB};
|
int *refs[6] = {&fgR, &fgG, &fgB, &bgR, &bgG, &bgB};
|
||||||
for(int i = 0; i < 6; i++)
|
for(int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
String::Stream ss;
|
||||||
ss << *refs[i];
|
ss << *refs[i];
|
||||||
ui::Textbox *colorComponent = new ui::Textbox(ui::Point(currentX, baseline), ui::Point(27, 17), ss.str());
|
ui::Textbox *colorComponent = new ui::Textbox(ui::Point(currentX, baseline), ui::Point(27, 17), ss.str());
|
||||||
currentX += 28;
|
currentX += 28;
|
||||||
@ -385,8 +384,8 @@ FontEditor::FontEditor(std::string _header):
|
|||||||
PreviewAction(FontEditor *_v): v(_v) {}
|
PreviewAction(FontEditor *_v): v(_v) {}
|
||||||
void TextChangedCallback(ui::Textbox *box)
|
void TextChangedCallback(ui::Textbox *box)
|
||||||
{
|
{
|
||||||
std::stringstream ss(box->GetText());
|
String::Stream ss(box->GetText());
|
||||||
std::string text;
|
String text;
|
||||||
while(!ss.eof())
|
while(!ss.eof())
|
||||||
{
|
{
|
||||||
if(ss.peek() == '\n')
|
if(ss.peek() == '\n')
|
||||||
@ -399,12 +398,12 @@ FontEditor::FontEditor(std::string _header):
|
|||||||
if(ss.fail())
|
if(ss.fail())
|
||||||
{
|
{
|
||||||
ss.clear();
|
ss.clear();
|
||||||
char ch = ss.get();
|
String::value_type ch = ss.get();
|
||||||
if(!ss.eof())
|
if(!ss.eof())
|
||||||
text.push_back(ch);
|
text.push_back(ch);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
text.push_back((char)ch);
|
text.push_back(ch);
|
||||||
}
|
}
|
||||||
v->outputPreview->SetText(text);
|
v->outputPreview->SetText(text);
|
||||||
}
|
}
|
||||||
@ -416,7 +415,7 @@ FontEditor::FontEditor(std::string _header):
|
|||||||
inputPreview->Appearance.VerticalAlign = ui::Appearance::AlignTop;
|
inputPreview->Appearance.VerticalAlign = ui::Appearance::AlignTop;
|
||||||
inputPreview->SetActionCallback(new PreviewAction(this));
|
inputPreview->SetActionCallback(new PreviewAction(this));
|
||||||
|
|
||||||
std::stringstream input;
|
String::Stream input;
|
||||||
for(unsigned int ch = 0x20; ch <= 0xFF; ch++)
|
for(unsigned int ch = 0x20; ch <= 0xFF; ch++)
|
||||||
{
|
{
|
||||||
if(!(ch & 0x3F))
|
if(!(ch & 0x3F))
|
||||||
@ -493,7 +492,7 @@ void FontEditor::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bo
|
|||||||
|
|
||||||
void FontEditor::UpdateCharNumber()
|
void FontEditor::UpdateCharNumber()
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
String::Stream ss;
|
||||||
ss << std::hex << currentChar;
|
ss << std::hex << currentChar;
|
||||||
currentCharTextbox->SetText(ss.str());
|
currentCharTextbox->SetText(ss.str());
|
||||||
}
|
}
|
||||||
|
@ -13,19 +13,19 @@
|
|||||||
class FontEditor: public ui::Window
|
class FontEditor: public ui::Window
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string header;
|
ByteString header;
|
||||||
std::array<char, 256> fontWidths;
|
std::array<char, 256> fontWidths;
|
||||||
std::array<std::array<std::array<char, MAX_WIDTH>, FONT_H>, 256> fontPixels;
|
std::array<std::array<std::array<char, MAX_WIDTH>, FONT_H>, 256> fontPixels;
|
||||||
|
|
||||||
std::vector<unsigned char> fontData;
|
std::vector<unsigned char> fontData;
|
||||||
std::vector<short> fontPtrs;
|
std::vector<short> fontPtrs;
|
||||||
|
|
||||||
std::string beforeFontData;
|
ByteString beforeFontData;
|
||||||
std::string afterFontData;
|
ByteString afterFontData;
|
||||||
std::string afterFontPtrs;
|
ByteString afterFontPtrs;
|
||||||
|
|
||||||
void ReadHeader(std::string header);
|
void ReadHeader(ByteString header);
|
||||||
void WriteHeader(std::string header, std::vector<unsigned char> const &fontData, std::vector<short> const &fontPtrs);
|
void WriteHeader(ByteString header, std::vector<unsigned char> const &fontData, std::vector<short> const &fontPtrs);
|
||||||
static void PackData(
|
static void PackData(
|
||||||
std::array<char, 256> const &fontWidths,
|
std::array<char, 256> const &fontWidths,
|
||||||
std::array<std::array<std::array<char, MAX_WIDTH>, FONT_H>, 256> const &fontPixels,
|
std::array<std::array<std::array<char, MAX_WIDTH>, FONT_H>, 256> const &fontPixels,
|
||||||
@ -57,7 +57,7 @@ private:
|
|||||||
void Save();
|
void Save();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FontEditor(std::string header);
|
FontEditor(ByteString header);
|
||||||
|
|
||||||
void OnDraw();
|
void OnDraw();
|
||||||
void OnMouseDown(int x, int y, unsigned button);
|
void OnMouseDown(int x, int y, unsigned button);
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
return newTexture;
|
return newTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
DecorationTool(Renderer *ren_, int decoMode, string name, string description, int r, int g, int b, std::string identifier):
|
DecorationTool(Renderer *ren_, int decoMode, ByteString name, String description, int r, int g, int b, ByteString identifier):
|
||||||
Tool(decoMode, name, description, r, g, b, identifier),
|
Tool(decoMode, name, description, r, g, b, identifier),
|
||||||
Red(0),
|
Red(0),
|
||||||
Green(0),
|
Green(0),
|
||||||
|
@ -4,16 +4,16 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
Favorite::Favorite():
|
Favorite::Favorite():
|
||||||
favoritesList(std::vector<std::string>())
|
favoritesList(std::vector<ByteString>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> Favorite::GetFavoritesList()
|
std::vector<ByteString> Favorite::GetFavoritesList()
|
||||||
{
|
{
|
||||||
return favoritesList;
|
return favoritesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Favorite::IsFavorite(std::string identifier)
|
bool Favorite::IsFavorite(ByteString identifier)
|
||||||
{
|
{
|
||||||
return std::find(favoritesList.begin(), favoritesList.end(), identifier) != favoritesList.end();
|
return std::find(favoritesList.begin(), favoritesList.end(), identifier) != favoritesList.end();
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ bool Favorite::AnyFavorites()
|
|||||||
return favoritesList.size() == 0;
|
return favoritesList.size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Favorite::AddFavorite(std::string identifier)
|
void Favorite::AddFavorite(ByteString identifier)
|
||||||
{
|
{
|
||||||
if (!IsFavorite(identifier))
|
if (!IsFavorite(identifier))
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ void Favorite::AddFavorite(std::string identifier)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Favorite::RemoveFavorite(std::string identifier)
|
void Favorite::RemoveFavorite(ByteString identifier)
|
||||||
{
|
{
|
||||||
favoritesList.erase(std::remove(favoritesList.begin(), favoritesList.end(), identifier), favoritesList.end());
|
favoritesList.erase(std::remove(favoritesList.begin(), favoritesList.end(), identifier), favoritesList.end());
|
||||||
}
|
}
|
||||||
@ -43,5 +43,5 @@ void Favorite::SaveFavoritesToPrefs()
|
|||||||
|
|
||||||
void Favorite::LoadFavoritesFromPrefs()
|
void Favorite::LoadFavoritesFromPrefs()
|
||||||
{
|
{
|
||||||
favoritesList = Client::Ref().GetPrefStringArray("Favorites");
|
favoritesList = Client::Ref().GetPrefByteStringArray("Favorites");
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
#ifndef FAVORITE_H
|
#ifndef FAVORITE_H
|
||||||
#define FAVORITE_H
|
#define FAVORITE_H
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/Singleton.h"
|
#include "common/Singleton.h"
|
||||||
|
|
||||||
class Favorite : public Singleton<Favorite>
|
class Favorite : public Singleton<Favorite>
|
||||||
{
|
{
|
||||||
std::vector<std::string> favoritesList;
|
std::vector<ByteString> favoritesList;
|
||||||
public:
|
public:
|
||||||
Favorite();
|
Favorite();
|
||||||
|
|
||||||
std::vector<std::string> GetFavoritesList();
|
std::vector<ByteString> GetFavoritesList();
|
||||||
bool IsFavorite(std::string identifier);
|
bool IsFavorite(ByteString identifier);
|
||||||
bool AnyFavorites();
|
bool AnyFavorites();
|
||||||
|
|
||||||
void AddFavorite(std::string identifier);
|
void AddFavorite(ByteString identifier);
|
||||||
void RemoveFavorite(std::string identifier);
|
void RemoveFavorite(ByteString identifier);
|
||||||
|
|
||||||
void SaveFavoritesToPrefs();
|
void SaveFavoritesToPrefs();
|
||||||
void LoadFavoritesFromPrefs();
|
void LoadFavoritesFromPrefs();
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
}
|
}
|
||||||
catch(GameModelException & ex)
|
catch(GameModelException & ex)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Cannot open save", ex.what());
|
new ErrorMessage("Cannot open save", ByteString(ex.what()).FromUtf8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ public:
|
|||||||
}
|
}
|
||||||
catch(GameModelException & ex)
|
catch(GameModelException & ex)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Cannot open save", ex.what());
|
new ErrorMessage("Cannot open save", ByteString(ex.what()).FromUtf8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ int GameController::GetSignAt(int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assumed to already be a valid sign
|
// assumed to already be a valid sign
|
||||||
std::string GameController::GetSignText(int signID)
|
String GameController::GetSignText(int signID)
|
||||||
{
|
{
|
||||||
return gameModel->GetSimulation()->signs[signID].text;
|
return gameModel->GetSimulation()->signs[signID].text;
|
||||||
}
|
}
|
||||||
@ -573,7 +573,7 @@ void GameController::ToolClick(int toolSelection, ui::Point point)
|
|||||||
activeTool->Click(sim, cBrush, point);
|
activeTool->Click(sim, cBrush, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GameController::StampRegion(ui::Point point1, ui::Point point2, bool includePressure)
|
ByteString GameController::StampRegion(ui::Point point1, ui::Point point2, bool includePressure)
|
||||||
{
|
{
|
||||||
bool incPressure = Client::Ref().GetPrefBool("Simulation.IncludePressure", true);
|
bool incPressure = Client::Ref().GetPrefBool("Simulation.IncludePressure", true);
|
||||||
if (!incPressure)
|
if (!incPressure)
|
||||||
@ -583,7 +583,7 @@ std::string GameController::StampRegion(ui::Point point1, ui::Point point2, bool
|
|||||||
if(newSave)
|
if(newSave)
|
||||||
{
|
{
|
||||||
newSave->paused = gameModel->GetPaused();
|
newSave->paused = gameModel->GetPaused();
|
||||||
std::string stampName = Client::Ref().AddStamp(newSave);
|
ByteString stampName = Client::Ref().AddStamp(newSave);
|
||||||
delete newSave;
|
delete newSave;
|
||||||
if (stampName.length() == 0)
|
if (stampName.length() == 0)
|
||||||
new ErrorMessage("Could not create stamp", "Error serializing save file");
|
new ErrorMessage("Could not create stamp", "Error serializing save file");
|
||||||
@ -666,15 +666,15 @@ bool GameController::MouseUp(int x, int y, unsigned button, char type)
|
|||||||
if (foundSignID != -1)
|
if (foundSignID != -1)
|
||||||
{
|
{
|
||||||
sign foundSign = gameModel->GetSimulation()->signs[foundSignID];
|
sign foundSign = gameModel->GetSimulation()->signs[foundSignID];
|
||||||
std::string str = foundSign.text;
|
String str = foundSign.text;
|
||||||
char type;
|
String::value_type type;
|
||||||
int pos = sign::splitsign(str, &type);
|
int pos = sign::splitsign(str, &type);
|
||||||
if (pos)
|
if (pos)
|
||||||
{
|
{
|
||||||
ret = false;
|
ret = false;
|
||||||
if (type == 'c' || type == 't' || type == 's')
|
if (type == 'c' || type == 't' || type == 's')
|
||||||
{
|
{
|
||||||
std::string link = str.substr(3, pos-3);
|
String link = str.substr(3, pos-3);
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case 'c':
|
case 'c':
|
||||||
@ -687,8 +687,8 @@ bool GameController::MouseUp(int x, int y, unsigned button, char type)
|
|||||||
case 't':
|
case 't':
|
||||||
{
|
{
|
||||||
// buff is already confirmed to be a number by sign::splitsign
|
// buff is already confirmed to be a number by sign::splitsign
|
||||||
std::stringstream uri;
|
ByteString::Stream uri;
|
||||||
uri << "http://powdertoy.co.uk/Discussions/Thread/View.html?Thread=" << link;
|
uri << "http://powdertoy.co.uk/Discussions/Thread/View.html?Thread=" << link.ToUtf8();
|
||||||
Platform::OpenURI(uri.str());
|
Platform::OpenURI(uri.str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1175,7 +1175,7 @@ void GameController::SetActiveTool(int toolSelection, Tool * tool)
|
|||||||
((PropertyTool *)tool)->OpenWindow(gameModel->GetSimulation());
|
((PropertyTool *)tool)->OpenWindow(gameModel->GetSimulation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::SetActiveTool(int toolSelection, std::string identifier)
|
void GameController::SetActiveTool(int toolSelection, ByteString identifier)
|
||||||
{
|
{
|
||||||
Tool *tool = gameModel->GetToolFromIdentifier(identifier);
|
Tool *tool = gameModel->GetToolFromIdentifier(identifier);
|
||||||
if (!tool)
|
if (!tool)
|
||||||
@ -1198,7 +1198,7 @@ void GameController::SetReplaceModeFlags(int flags)
|
|||||||
gameModel->GetSimulation()->replaceModeFlags = flags;
|
gameModel->GetSimulation()->replaceModeFlags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::OpenSearch(std::string searchText)
|
void GameController::OpenSearch(String searchText)
|
||||||
{
|
{
|
||||||
if(!search)
|
if(!search)
|
||||||
search = new SearchController(new SearchCallback(this));
|
search = new SearchController(new SearchCallback(this));
|
||||||
@ -1524,7 +1524,7 @@ void GameController::Vote(int direction)
|
|||||||
}
|
}
|
||||||
catch(GameModelException & ex)
|
catch(GameModelException & ex)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error while voting", ex.what());
|
new ErrorMessage("Error while voting", ByteString(ex.what()).FromUtf8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1555,14 +1555,14 @@ void GameController::ReloadSim()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GameController::ElementResolve(int type, int ctype)
|
ByteString GameController::ElementResolve(int type, int ctype)
|
||||||
{
|
{
|
||||||
if(gameModel && gameModel->GetSimulation())
|
if(gameModel && gameModel->GetSimulation())
|
||||||
{
|
{
|
||||||
if (type == PT_LIFE && ctype >= 0 && ctype < NGOL)
|
if (type == PT_LIFE && ctype >= 0 && ctype < NGOL)
|
||||||
return gameModel->GetSimulation()->gmenu[ctype].name;
|
return gameModel->GetSimulation()->gmenu[ctype].name;
|
||||||
else if (type >= 0 && type < PT_NUM)
|
else if (type >= 0 && type < PT_NUM)
|
||||||
return std::string(gameModel->GetSimulation()->elements[type].Name);
|
return gameModel->GetSimulation()->elements[type].Name;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -1577,10 +1577,10 @@ bool GameController::IsValidElement(int type)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GameController::WallName(int type)
|
String GameController::WallName(int type)
|
||||||
{
|
{
|
||||||
if(gameModel && gameModel->GetSimulation() && type >= 0 && type < UI_WALLCOUNT)
|
if(gameModel && gameModel->GetSimulation() && type >= 0 && type < UI_WALLCOUNT)
|
||||||
return std::string(gameModel->GetSimulation()->wtypes[type].name);
|
return gameModel->GetSimulation()->wtypes[type].name;
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -1596,13 +1596,13 @@ void GameController::NotifyAuthUserChanged(Client * sender)
|
|||||||
gameModel->SetUser(newUser);
|
gameModel->SetUser(newUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::NotifyNewNotification(Client * sender, std::pair<std::string, std::string> notification)
|
void GameController::NotifyNewNotification(Client * sender, std::pair<String, ByteString> notification)
|
||||||
{
|
{
|
||||||
class LinkNotification : public Notification
|
class LinkNotification : public Notification
|
||||||
{
|
{
|
||||||
std::string link;
|
ByteString link;
|
||||||
public:
|
public:
|
||||||
LinkNotification(std::string link_, std::string message) : Notification(message), link(link_) {}
|
LinkNotification(ByteString link_, String message) : Notification(message), link(link_) {}
|
||||||
virtual ~LinkNotification() {}
|
virtual ~LinkNotification() {}
|
||||||
|
|
||||||
virtual void Action()
|
virtual void Action()
|
||||||
@ -1632,13 +1632,13 @@ void GameController::NotifyUpdateAvailable(Client * sender)
|
|||||||
{
|
{
|
||||||
GameController * c;
|
GameController * c;
|
||||||
public:
|
public:
|
||||||
UpdateNotification(GameController * c, std::string message) : Notification(message), c(c) {}
|
UpdateNotification(GameController * c, String message) : Notification(message), c(c) {}
|
||||||
virtual ~UpdateNotification() {}
|
virtual ~UpdateNotification() {}
|
||||||
|
|
||||||
virtual void Action()
|
virtual void Action()
|
||||||
{
|
{
|
||||||
UpdateInfo info = Client::Ref().GetUpdateInfo();
|
UpdateInfo info = Client::Ref().GetUpdateInfo();
|
||||||
std::stringstream updateMessage;
|
String::Stream updateMessage;
|
||||||
updateMessage << "Are you sure you want to run the updater? Please save any changes before updating.\n\nCurrent version:\n ";
|
updateMessage << "Are you sure you want to run the updater? Please save any changes before updating.\n\nCurrent version:\n ";
|
||||||
|
|
||||||
#ifdef SNAPSHOT
|
#ifdef SNAPSHOT
|
||||||
@ -1674,16 +1674,16 @@ void GameController::NotifyUpdateAvailable(Client * sender)
|
|||||||
{
|
{
|
||||||
case UpdateInfo::Snapshot:
|
case UpdateInfo::Snapshot:
|
||||||
#if MOD_ID > 0
|
#if MOD_ID > 0
|
||||||
gameModel->AddNotification(new UpdateNotification(this, std::string("A new mod update is available - click here to update")));
|
gameModel->AddNotification(new UpdateNotification(this, "A new mod update is available - click here to update"));
|
||||||
#else
|
#else
|
||||||
gameModel->AddNotification(new UpdateNotification(this, std::string("A new snapshot is available - click here to update")));
|
gameModel->AddNotification(new UpdateNotification(this, "A new snapshot is available - click here to update"));
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case UpdateInfo::Stable:
|
case UpdateInfo::Stable:
|
||||||
gameModel->AddNotification(new UpdateNotification(this, std::string("A new version is available - click here to update")));
|
gameModel->AddNotification(new UpdateNotification(this, "A new version is available - click here to update"));
|
||||||
break;
|
break;
|
||||||
case UpdateInfo::Beta:
|
case UpdateInfo::Beta:
|
||||||
gameModel->AddNotification(new UpdateNotification(this, std::string("A new beta is available - click here to update")));
|
gameModel->AddNotification(new UpdateNotification(this, "A new beta is available - click here to update"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
~GameController();
|
~GameController();
|
||||||
GameView * GetView();
|
GameView * GetView();
|
||||||
int GetSignAt(int x, int y);
|
int GetSignAt(int x, int y);
|
||||||
std::string GetSignText(int signID);
|
String GetSignText(int signID);
|
||||||
|
|
||||||
bool MouseMove(int x, int y, int dx, int dy);
|
bool MouseMove(int x, int y, int dx, int dy);
|
||||||
bool MouseDown(int x, int y, unsigned button);
|
bool MouseDown(int x, int y, unsigned button);
|
||||||
@ -89,7 +89,7 @@ public:
|
|||||||
void DrawRect(int toolSelection, ui::Point point1, ui::Point point2);
|
void DrawRect(int toolSelection, ui::Point point1, ui::Point point2);
|
||||||
void DrawLine(int toolSelection, ui::Point point1, ui::Point point2);
|
void DrawLine(int toolSelection, ui::Point point1, ui::Point point2);
|
||||||
void DrawFill(int toolSelection, ui::Point point);
|
void DrawFill(int toolSelection, ui::Point point);
|
||||||
std::string StampRegion(ui::Point point1, ui::Point point2, bool includePressure);
|
ByteString StampRegion(ui::Point point1, ui::Point point2, bool includePressure);
|
||||||
void CopyRegion(ui::Point point1, ui::Point point2, bool includePressure);
|
void CopyRegion(ui::Point point1, ui::Point point2, bool includePressure);
|
||||||
void CutRegion(ui::Point point1, ui::Point point2, bool includePressure);
|
void CutRegion(ui::Point point1, ui::Point point2, bool includePressure);
|
||||||
void Update();
|
void Update();
|
||||||
@ -109,7 +109,7 @@ public:
|
|||||||
void RebuildFavoritesMenu();
|
void RebuildFavoritesMenu();
|
||||||
Tool * GetActiveTool(int selection);
|
Tool * GetActiveTool(int selection);
|
||||||
void SetActiveTool(int toolSelection, Tool * tool);
|
void SetActiveTool(int toolSelection, Tool * tool);
|
||||||
void SetActiveTool(int toolSelection, std::string identifier);
|
void SetActiveTool(int toolSelection, ByteString identifier);
|
||||||
void SetLastTool(Tool * tool);
|
void SetLastTool(Tool * tool);
|
||||||
int GetReplaceModeFlags();
|
int GetReplaceModeFlags();
|
||||||
void SetReplaceModeFlags(int flags);
|
void SetReplaceModeFlags(int flags);
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
void SetToolStrength(float value);
|
void SetToolStrength(float value);
|
||||||
void LoadSaveFile(SaveFile * file);
|
void LoadSaveFile(SaveFile * file);
|
||||||
void LoadSave(SaveInfo * save);
|
void LoadSave(SaveInfo * save);
|
||||||
void OpenSearch(std::string searchText);
|
void OpenSearch(String searchText);
|
||||||
void OpenLogin();
|
void OpenLogin();
|
||||||
void OpenProfile();
|
void OpenProfile();
|
||||||
void OpenTags();
|
void OpenTags();
|
||||||
@ -147,9 +147,9 @@ public:
|
|||||||
bool MouseInZoom(ui::Point position);
|
bool MouseInZoom(ui::Point position);
|
||||||
ui::Point PointTranslate(ui::Point point);
|
ui::Point PointTranslate(ui::Point point);
|
||||||
ui::Point NormaliseBlockCoord(ui::Point point);
|
ui::Point NormaliseBlockCoord(ui::Point point);
|
||||||
std::string ElementResolve(int type, int ctype);
|
ByteString ElementResolve(int type, int ctype);
|
||||||
bool IsValidElement(int type);
|
bool IsValidElement(int type);
|
||||||
std::string WallName(int type);
|
String WallName(int type);
|
||||||
int Record(bool record);
|
int Record(bool record);
|
||||||
|
|
||||||
void ResetAir();
|
void ResetAir();
|
||||||
@ -167,7 +167,7 @@ public:
|
|||||||
|
|
||||||
virtual void NotifyUpdateAvailable(Client * sender);
|
virtual void NotifyUpdateAvailable(Client * sender);
|
||||||
virtual void NotifyAuthUserChanged(Client * sender);
|
virtual void NotifyAuthUserChanged(Client * sender);
|
||||||
virtual void NotifyNewNotification(Client * sender, std::pair<std::string, std::string> notification);
|
virtual void NotifyNewNotification(Client * sender, std::pair<String, ByteString> notification);
|
||||||
void RunUpdater();
|
void RunUpdater();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ GameModel::GameModel():
|
|||||||
brushList.push_back(new TriangleBrush(ui::Point(4, 4)));
|
brushList.push_back(new TriangleBrush(ui::Point(4, 4)));
|
||||||
|
|
||||||
//Load more from brushes folder
|
//Load more from brushes folder
|
||||||
std::vector<string> brushFiles = Client::Ref().DirectorySearch(BRUSH_DIR, "", ".ptb");
|
std::vector<ByteString> brushFiles = Client::Ref().DirectorySearch(BRUSH_DIR, "", ".ptb");
|
||||||
for (size_t i = 0; i < brushFiles.size(); i++)
|
for (size_t i = 0; i < brushFiles.size(); i++)
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> brushData = Client::Ref().ReadFile(brushFiles[i]);
|
std::vector<unsigned char> brushData = Client::Ref().ReadFile(brushFiles[i]);
|
||||||
@ -234,7 +234,7 @@ void GameModel::BuildMenus()
|
|||||||
if(activeMenu != -1)
|
if(activeMenu != -1)
|
||||||
lastMenu = activeMenu;
|
lastMenu = activeMenu;
|
||||||
|
|
||||||
std::string activeToolIdentifiers[4];
|
ByteString activeToolIdentifiers[4];
|
||||||
if(regularToolset[0])
|
if(regularToolset[0])
|
||||||
activeToolIdentifiers[0] = regularToolset[0]->GetIdentifier();
|
activeToolIdentifiers[0] = regularToolset[0]->GetIdentifier();
|
||||||
if(regularToolset[1])
|
if(regularToolset[1])
|
||||||
@ -264,7 +264,7 @@ void GameModel::BuildMenus()
|
|||||||
//Create menus
|
//Create menus
|
||||||
for (int i = 0; i < SC_TOTAL; i++)
|
for (int i = 0; i < SC_TOTAL; i++)
|
||||||
{
|
{
|
||||||
menuList.push_back(new Menu((const char)sim->msections[i].icon[0], sim->msections[i].name, sim->msections[i].doshow));
|
menuList.push_back(new Menu(sim->msections[i].icon[0], sim->msections[i].name, sim->msections[i].doshow));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Build menus from Simulation elements
|
//Build menus from Simulation elements
|
||||||
@ -305,14 +305,14 @@ void GameModel::BuildMenus()
|
|||||||
//Build menu for GOL types
|
//Build menu for GOL types
|
||||||
for(int i = 0; i < NGOL; i++)
|
for(int i = 0; i < NGOL; i++)
|
||||||
{
|
{
|
||||||
Tool * tempTool = new ElementTool(PT_LIFE|PMAPID(i), sim->gmenu[i].name, std::string(sim->gmenu[i].description), PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour), "DEFAULT_PT_LIFE_"+std::string(sim->gmenu[i].name));
|
Tool * tempTool = new ElementTool(PT_LIFE|PMAPID(i), sim->gmenu[i].name, sim->gmenu[i].description, PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour), "DEFAULT_PT_LIFE_"+sim->gmenu[i].name);
|
||||||
menuList[SC_LIFE]->AddTool(tempTool);
|
menuList[SC_LIFE]->AddTool(tempTool);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Build other menus from wall data
|
//Build other menus from wall data
|
||||||
for(int i = 0; i < UI_WALLCOUNT; i++)
|
for(int i = 0; i < UI_WALLCOUNT; i++)
|
||||||
{
|
{
|
||||||
Tool * tempTool = new WallTool(i, "", std::string(sim->wtypes[i].descs), PIXR(sim->wtypes[i].colour), PIXG(sim->wtypes[i].colour), PIXB(sim->wtypes[i].colour), sim->wtypes[i].identifier, sim->wtypes[i].textureGen);
|
Tool * tempTool = new WallTool(i, "", sim->wtypes[i].descs, PIXR(sim->wtypes[i].colour), PIXG(sim->wtypes[i].colour), PIXB(sim->wtypes[i].colour), sim->wtypes[i].identifier, sim->wtypes[i].textureGen);
|
||||||
menuList[SC_WALL]->AddTool(tempTool);
|
menuList[SC_WALL]->AddTool(tempTool);
|
||||||
//sim->wtypes[i]
|
//sim->wtypes[i]
|
||||||
}
|
}
|
||||||
@ -386,7 +386,7 @@ void GameModel::BuildFavoritesMenu()
|
|||||||
{
|
{
|
||||||
menuList[SC_FAVORITES]->ClearTools();
|
menuList[SC_FAVORITES]->ClearTools();
|
||||||
|
|
||||||
std::vector<std::string> favList = Favorite::Ref().GetFavoritesList();
|
std::vector<ByteString> favList = Favorite::Ref().GetFavoritesList();
|
||||||
for (size_t i = 0; i < favList.size(); i++)
|
for (size_t i = 0; i < favList.size(); i++)
|
||||||
{
|
{
|
||||||
Tool *tool = GetToolFromIdentifier(favList[i]);
|
Tool *tool = GetToolFromIdentifier(favList[i]);
|
||||||
@ -403,7 +403,7 @@ void GameModel::BuildFavoritesMenu()
|
|||||||
notifyLastToolChanged();
|
notifyLastToolChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
Tool * GameModel::GetToolFromIdentifier(std::string identifier)
|
Tool * GameModel::GetToolFromIdentifier(ByteString identifier)
|
||||||
{
|
{
|
||||||
for (std::vector<Menu*>::iterator iter = menuList.begin(), end = menuList.end(); iter != end; ++iter)
|
for (std::vector<Menu*>::iterator iter = menuList.begin(), end = menuList.end(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
@ -657,8 +657,8 @@ void GameModel::SetSave(SaveInfo * newSave)
|
|||||||
saveData->authors["type"] = "save";
|
saveData->authors["type"] = "save";
|
||||||
saveData->authors["id"] = newSave->id;
|
saveData->authors["id"] = newSave->id;
|
||||||
saveData->authors["username"] = newSave->userName;
|
saveData->authors["username"] = newSave->userName;
|
||||||
saveData->authors["title"] = newSave->name;
|
saveData->authors["title"] = newSave->name.ToUtf8();
|
||||||
saveData->authors["description"] = newSave->Description;
|
saveData->authors["description"] = newSave->Description.ToUtf8();
|
||||||
saveData->authors["published"] = (int)newSave->Published;
|
saveData->authors["published"] = (int)newSave->Published;
|
||||||
saveData->authors["date"] = newSave->updatedDate;
|
saveData->authors["date"] = newSave->updatedDate;
|
||||||
}
|
}
|
||||||
@ -912,7 +912,7 @@ void GameModel::SetPaused(bool pauseState)
|
|||||||
{
|
{
|
||||||
if (!pauseState && sim->debug_currentParticle > 0)
|
if (!pauseState && sim->debug_currentParticle > 0)
|
||||||
{
|
{
|
||||||
std::stringstream logmessage;
|
String::Stream logmessage;
|
||||||
logmessage << "Updated particles from #" << sim->debug_currentParticle << " to end due to unpause";
|
logmessage << "Updated particles from #" << sim->debug_currentParticle << " to end due to unpause";
|
||||||
sim->UpdateParticles(sim->debug_currentParticle, NPART);
|
sim->UpdateParticles(sim->debug_currentParticle, NPART);
|
||||||
sim->AfterSim();
|
sim->AfterSim();
|
||||||
@ -1048,17 +1048,17 @@ GameSave * GameModel::GetPlaceSave()
|
|||||||
return placeSave;
|
return placeSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameModel::Log(string message, bool printToFile)
|
void GameModel::Log(String message, bool printToFile)
|
||||||
{
|
{
|
||||||
consoleLog.push_front(message);
|
consoleLog.push_front(message);
|
||||||
if(consoleLog.size()>100)
|
if(consoleLog.size()>100)
|
||||||
consoleLog.pop_back();
|
consoleLog.pop_back();
|
||||||
notifyLogChanged(message);
|
notifyLogChanged(message);
|
||||||
if (printToFile)
|
if (printToFile)
|
||||||
std::cout << message << std::endl;
|
std::cout << message.ToUtf8() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
deque<string> GameModel::GetLog()
|
deque<String> GameModel::GetLog()
|
||||||
{
|
{
|
||||||
return consoleLog;
|
return consoleLog;
|
||||||
}
|
}
|
||||||
@ -1088,24 +1088,24 @@ void GameModel::RemoveNotification(Notification * notification)
|
|||||||
notifyNotificationsChanged();
|
notifyNotificationsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameModel::SetToolTip(std::string text)
|
void GameModel::SetToolTip(String text)
|
||||||
{
|
{
|
||||||
toolTip = text;
|
toolTip = text;
|
||||||
notifyToolTipChanged();
|
notifyToolTipChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameModel::SetInfoTip(std::string text)
|
void GameModel::SetInfoTip(String text)
|
||||||
{
|
{
|
||||||
infoTip = text;
|
infoTip = text;
|
||||||
notifyInfoTipChanged();
|
notifyInfoTipChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GameModel::GetToolTip()
|
String GameModel::GetToolTip()
|
||||||
{
|
{
|
||||||
return toolTip;
|
return toolTip;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GameModel::GetInfoTip()
|
String GameModel::GetInfoTip()
|
||||||
{
|
{
|
||||||
return infoTip;
|
return infoTip;
|
||||||
}
|
}
|
||||||
@ -1246,7 +1246,7 @@ void GameModel::notifyPlaceSaveChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameModel::notifyLogChanged(string entry)
|
void GameModel::notifyLogChanged(String entry)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < observers.size(); i++)
|
for (size_t i = 0; i < observers.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ private:
|
|||||||
//unsigned char * clipboardData;
|
//unsigned char * clipboardData;
|
||||||
GameSave * clipboard;
|
GameSave * clipboard;
|
||||||
GameSave * placeSave;
|
GameSave * placeSave;
|
||||||
deque<string> consoleLog;
|
deque<String> consoleLog;
|
||||||
vector<GameView*> observers;
|
vector<GameView*> observers;
|
||||||
vector<Tool*> toolList;
|
vector<Tool*> toolList;
|
||||||
|
|
||||||
@ -77,8 +77,8 @@ private:
|
|||||||
|
|
||||||
int edgeMode;
|
int edgeMode;
|
||||||
|
|
||||||
std::string infoTip;
|
String infoTip;
|
||||||
std::string toolTip;
|
String toolTip;
|
||||||
//bool zoomEnabled;
|
//bool zoomEnabled;
|
||||||
void notifyRendererChanged();
|
void notifyRendererChanged();
|
||||||
void notifySimulationChanged();
|
void notifySimulationChanged();
|
||||||
@ -98,7 +98,7 @@ private:
|
|||||||
void notifyColourPresetsChanged();
|
void notifyColourPresetsChanged();
|
||||||
void notifyColourActivePresetChanged();
|
void notifyColourActivePresetChanged();
|
||||||
void notifyNotificationsChanged();
|
void notifyNotificationsChanged();
|
||||||
void notifyLogChanged(string entry);
|
void notifyLogChanged(String entry);
|
||||||
void notifyInfoTipChanged();
|
void notifyInfoTipChanged();
|
||||||
void notifyToolTipChanged();
|
void notifyToolTipChanged();
|
||||||
void notifyQuickOptionsChanged();
|
void notifyQuickOptionsChanged();
|
||||||
@ -123,10 +123,10 @@ public:
|
|||||||
void SetColourSelectorColour(ui::Colour colour);
|
void SetColourSelectorColour(ui::Colour colour);
|
||||||
ui::Colour GetColourSelectorColour();
|
ui::Colour GetColourSelectorColour();
|
||||||
|
|
||||||
void SetToolTip(std::string text);
|
void SetToolTip(String text);
|
||||||
void SetInfoTip(std::string text);
|
void SetInfoTip(String text);
|
||||||
std::string GetToolTip();
|
String GetToolTip();
|
||||||
std::string GetInfoTip();
|
String GetInfoTip();
|
||||||
|
|
||||||
void BuildMenus();
|
void BuildMenus();
|
||||||
void BuildFavoritesMenu();
|
void BuildFavoritesMenu();
|
||||||
@ -149,7 +149,7 @@ public:
|
|||||||
float GetToolStrength();
|
float GetToolStrength();
|
||||||
Tool * GetLastTool();
|
Tool * GetLastTool();
|
||||||
void SetLastTool(Tool * newTool);
|
void SetLastTool(Tool * newTool);
|
||||||
Tool * GetToolFromIdentifier(std::string identifier);
|
Tool * GetToolFromIdentifier(ByteString identifier);
|
||||||
Tool * GetElementTool(int elementID);
|
Tool * GetElementTool(int elementID);
|
||||||
vector<Tool*> GetToolList();
|
vector<Tool*> GetToolList();
|
||||||
vector<Tool*> GetUnlistedTools();
|
vector<Tool*> GetUnlistedTools();
|
||||||
@ -200,8 +200,8 @@ public:
|
|||||||
ui::Point GetZoomWindowPosition();
|
ui::Point GetZoomWindowPosition();
|
||||||
void SetClipboard(GameSave * save);
|
void SetClipboard(GameSave * save);
|
||||||
void SetPlaceSave(GameSave * save);
|
void SetPlaceSave(GameSave * save);
|
||||||
void Log(string message, bool printToFile);
|
void Log(String message, bool printToFile);
|
||||||
deque<string> GetLog();
|
deque<String> GetLog();
|
||||||
GameSave * GetClipboard();
|
GameSave * GetClipboard();
|
||||||
GameSave * GetPlaceSave();
|
GameSave * GetPlaceSave();
|
||||||
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
#ifndef GAMEMODELEXCEPTION_H_
|
#ifndef GAMEMODELEXCEPTION_H_
|
||||||
#define GAMEMODELEXCEPTION_H_
|
#define GAMEMODELEXCEPTION_H_
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include <exception>
|
#include <exception>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
struct GameModelException: public exception {
|
struct GameModelException: public exception {
|
||||||
string message;
|
String message;
|
||||||
public:
|
public:
|
||||||
GameModelException(string message_): message(message_) {}
|
GameModelException(String message_): message(message_) {}
|
||||||
const char * what() const throw()
|
const char * what() const throw()
|
||||||
{
|
{
|
||||||
return message.c_str();
|
return message.ToUtf8().c_str();
|
||||||
}
|
}
|
||||||
~GameModelException() throw() {};
|
~GameModelException() throw() {};
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <sstream>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "GameView.h"
|
#include "GameView.h"
|
||||||
@ -40,10 +39,10 @@ private:
|
|||||||
bool leftDown;
|
bool leftDown;
|
||||||
bool showSplit;
|
bool showSplit;
|
||||||
int splitPosition;
|
int splitPosition;
|
||||||
std::string toolTip2;
|
String toolTip2;
|
||||||
SplitButtonAction * splitActionCallback;
|
SplitButtonAction * splitActionCallback;
|
||||||
public:
|
public:
|
||||||
SplitButton(ui::Point position, ui::Point size, std::string buttonText, std::string toolTip, std::string toolTip2, int split) :
|
SplitButton(ui::Point position, ui::Point size, String buttonText, String toolTip, String toolTip2, int split) :
|
||||||
Button(position, size, buttonText, toolTip),
|
Button(position, size, buttonText, toolTip),
|
||||||
showSplit(true),
|
showSplit(true),
|
||||||
splitPosition(split),
|
splitPosition(split),
|
||||||
@ -52,7 +51,7 @@ public:
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
void SetRightToolTip(std::string tooltip) { toolTip2 = tooltip; }
|
void SetRightToolTip(String tooltip) { toolTip2 = tooltip; }
|
||||||
bool GetShowSplit() { return showSplit; }
|
bool GetShowSplit() { return showSplit; }
|
||||||
void SetShowSplit(bool split) { showSplit = split; }
|
void SetShowSplit(bool split) { showSplit = split; }
|
||||||
SplitButtonAction * GetSplitActionCallback() { return splitActionCallback; }
|
SplitButtonAction * GetSplitActionCallback() { return splitActionCallback; }
|
||||||
@ -101,12 +100,12 @@ public:
|
|||||||
return;
|
return;
|
||||||
SetToolTip(x, y);
|
SetToolTip(x, y);
|
||||||
}
|
}
|
||||||
virtual void TextPosition(std::string ButtonText)
|
virtual void TextPosition(String ButtonText)
|
||||||
{
|
{
|
||||||
ui::Button::TextPosition(ButtonText);
|
ui::Button::TextPosition(ButtonText);
|
||||||
textPosition.X += 3;
|
textPosition.X += 3;
|
||||||
}
|
}
|
||||||
void SetToolTips(std::string newToolTip1, std::string newToolTip2)
|
void SetToolTips(String newToolTip1, String newToolTip2)
|
||||||
{
|
{
|
||||||
toolTip = newToolTip1;
|
toolTip = newToolTip1;
|
||||||
toolTip2 = newToolTip2;
|
toolTip2 = newToolTip2;
|
||||||
@ -183,7 +182,7 @@ GameView::GameView():
|
|||||||
buttonTip(""),
|
buttonTip(""),
|
||||||
isButtonTipFadingIn(false),
|
isButtonTipFadingIn(false),
|
||||||
introText(2048),
|
introText(2048),
|
||||||
introTextMessage(introTextData),
|
introTextMessage(ByteString(introTextData).FromAscii()),
|
||||||
|
|
||||||
doScreenshot(false),
|
doScreenshot(false),
|
||||||
screenshotIndex(0),
|
screenshotIndex(0),
|
||||||
@ -610,9 +609,9 @@ void GameView::NotifyMenuListChanged(GameModel * sender)
|
|||||||
{
|
{
|
||||||
if (menuList[i]->GetVisible())
|
if (menuList[i]->GetVisible())
|
||||||
{
|
{
|
||||||
std::string tempString = "";
|
String tempString = "";
|
||||||
tempString += menuList[i]->GetIcon();
|
tempString += menuList[i]->GetIcon();
|
||||||
std::string description = menuList[i]->GetDescription();
|
String description = menuList[i]->GetDescription();
|
||||||
if (i == SC_FAVORITES && Favorite::Ref().AnyFavorites())
|
if (i == SC_FAVORITES && Favorite::Ref().AnyFavorites())
|
||||||
description += " (Use ctrl+shift+click to favorite an element)";
|
description += " (Use ctrl+shift+click to favorite an element)";
|
||||||
ui::Button * tempButton = new ui::Button(ui::Point(WINDOWW-16, currentY), ui::Point(15, 15), tempString, description);
|
ui::Button * tempButton = new ui::Button(ui::Point(WINDOWW-16, currentY), ui::Point(15, 15), tempString, description);
|
||||||
@ -912,7 +911,7 @@ void GameView::NotifyUserChanged(GameModel * sender)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loginButton->SetText(sender->GetUser().Username);
|
loginButton->SetText(sender->GetUser().Username.FromUtf8());
|
||||||
((SplitButton*)loginButton)->SetShowSplit(true);
|
((SplitButton*)loginButton)->SetShowSplit(true);
|
||||||
((SplitButton*)loginButton)->SetRightToolTip("Edit profile");
|
((SplitButton*)loginButton)->SetRightToolTip("Edit profile");
|
||||||
}
|
}
|
||||||
@ -978,15 +977,15 @@ void GameView::NotifySaveChanged(GameModel * sender)
|
|||||||
tagSimulationButton->Enabled = sender->GetSave()->GetID();
|
tagSimulationButton->Enabled = sender->GetSave()->GetID();
|
||||||
if (sender->GetSave()->GetID())
|
if (sender->GetSave()->GetID())
|
||||||
{
|
{
|
||||||
std::stringstream tagsStream;
|
String::Stream tagsStream;
|
||||||
std::list<string> tags = sender->GetSave()->GetTags();
|
std::list<ByteString> tags = sender->GetSave()->GetTags();
|
||||||
if (tags.size())
|
if (tags.size())
|
||||||
{
|
{
|
||||||
for (std::list<std::string>::const_iterator iter = tags.begin(), begin = tags.begin(), end = tags.end(); iter != end; iter++)
|
for (std::list<ByteString>::const_iterator iter = tags.begin(), begin = tags.begin(), end = tags.end(); iter != end; iter++)
|
||||||
{
|
{
|
||||||
if (iter != begin)
|
if (iter != begin)
|
||||||
tagsStream << " ";
|
tagsStream << " ";
|
||||||
tagsStream << *iter;
|
tagsStream << iter->FromUtf8();
|
||||||
}
|
}
|
||||||
tagSimulationButton->SetText(tagsStream.str());
|
tagSimulationButton->SetText(tagsStream.str());
|
||||||
}
|
}
|
||||||
@ -1067,7 +1066,7 @@ int GameView::Record(bool record)
|
|||||||
{
|
{
|
||||||
time_t startTime = time(NULL);
|
time_t startTime = time(NULL);
|
||||||
recordingFolder = startTime;
|
recordingFolder = startTime;
|
||||||
std::stringstream recordingDir;
|
ByteString::Stream recordingDir;
|
||||||
recordingDir << "recordings" << PATH_SEP << recordingFolder;
|
recordingDir << "recordings" << PATH_SEP << recordingFolder;
|
||||||
Client::Ref().MakeDirectory("recordings");
|
Client::Ref().MakeDirectory("recordings");
|
||||||
Client::Ref().MakeDirectory(recordingDir.str().c_str());
|
Client::Ref().MakeDirectory(recordingDir.str().c_str());
|
||||||
@ -1327,7 +1326,7 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
|
|||||||
UpdateDrawMode();
|
UpdateDrawMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::ToolTip(ui::Point senderPosition, std::string toolTip)
|
void GameView::ToolTip(ui::Point senderPosition, String toolTip)
|
||||||
{
|
{
|
||||||
// buttom button tooltips
|
// buttom button tooltips
|
||||||
if (senderPosition.Y > Size.Y-17)
|
if (senderPosition.Y > Size.Y-17)
|
||||||
@ -1342,16 +1341,16 @@ void GameView::ToolTip(ui::Point senderPosition, std::string toolTip)
|
|||||||
else if(senderPosition.X > Size.X-BARSIZE)// < Size.Y-(quickOptionButtons.size()+1)*16)
|
else if(senderPosition.X > Size.X-BARSIZE)// < Size.Y-(quickOptionButtons.size()+1)*16)
|
||||||
{
|
{
|
||||||
this->toolTip = toolTip;
|
this->toolTip = toolTip;
|
||||||
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), senderPosition.Y+3);
|
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth(toolTip), senderPosition.Y+3);
|
||||||
if(toolTipPosition.Y+10 > Size.Y-MENUSIZE)
|
if(toolTipPosition.Y+10 > Size.Y-MENUSIZE)
|
||||||
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10);
|
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth(toolTip), Size.Y-MENUSIZE-10);
|
||||||
isToolTipFadingIn = true;
|
isToolTipFadingIn = true;
|
||||||
}
|
}
|
||||||
// element tooltips
|
// element tooltips
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->toolTip = toolTip;
|
this->toolTip = toolTip;
|
||||||
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10);
|
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth(toolTip), Size.Y-MENUSIZE-10);
|
||||||
isToolTipFadingIn = true;
|
isToolTipFadingIn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1490,8 +1489,8 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
if ((Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator
|
if ((Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator
|
||||||
|| Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin) && ctrl)
|
|| Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin) && ctrl)
|
||||||
{
|
{
|
||||||
std::string authorString = Client::Ref().GetAuthorInfo().toStyledString();
|
ByteString authorString = Client::Ref().GetAuthorInfo().toStyledString();
|
||||||
new InformationMessage("Save authorship info", authorString, true);
|
new InformationMessage("Save authorship info", authorString.FromUtf8(), true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
@ -1609,7 +1608,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
std::vector<std::string> stampList = Client::Ref().GetStamps(0, 1);
|
std::vector<ByteString> stampList = Client::Ref().GetStamps(0, 1);
|
||||||
if (stampList.size())
|
if (stampList.size())
|
||||||
{
|
{
|
||||||
SaveFile *saveFile = Client::Ref().GetStamp(stampList[0]);
|
SaveFile *saveFile = Client::Ref().GetStamp(stampList[0]);
|
||||||
@ -1735,13 +1734,13 @@ void GameView::OnTick(float dt)
|
|||||||
int foundSignID = c->GetSignAt(mousePosition.X, mousePosition.Y);
|
int foundSignID = c->GetSignAt(mousePosition.X, mousePosition.Y);
|
||||||
if (foundSignID != -1)
|
if (foundSignID != -1)
|
||||||
{
|
{
|
||||||
std::string str = c->GetSignText(foundSignID);
|
String str = c->GetSignText(foundSignID);
|
||||||
char type = '\0';
|
String::value_type type = '\0';
|
||||||
int pos = sign::splitsign(str, &type);
|
int pos = sign::splitsign(str, &type);
|
||||||
if (type == 'c' || type == 't' || type == 's')
|
if (type == 'c' || type == 't' || type == 's')
|
||||||
{
|
{
|
||||||
std::string linkSign = str.substr(3, pos-3);
|
String linkSign = str.substr(3, pos-3);
|
||||||
std::stringstream tooltip;
|
String::Stream tooltip;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case 'c':
|
case 'c':
|
||||||
@ -1903,7 +1902,7 @@ void GameView::NotifyNotificationsChanged(GameModel * sender)
|
|||||||
int currentY = YRES-23;
|
int currentY = YRES-23;
|
||||||
for(std::vector<Notification*>::iterator iter = notifications.begin(), end = notifications.end(); iter != end; ++iter)
|
for(std::vector<Notification*>::iterator iter = notifications.begin(), end = notifications.end(); iter != end; ++iter)
|
||||||
{
|
{
|
||||||
int width = (Graphics::textwidth((*iter)->Message.c_str()))+8;
|
int width = (Graphics::textwidth((*iter)->Message))+8;
|
||||||
ui::Button * tempButton = new ui::Button(ui::Point(XRES-width-22, currentY), ui::Point(width, 15), (*iter)->Message);
|
ui::Button * tempButton = new ui::Button(ui::Point(XRES-width-22, currentY), ui::Point(width, 15), (*iter)->Message);
|
||||||
tempButton->SetActionCallback(new NotificationButtonAction(*iter));
|
tempButton->SetActionCallback(new NotificationButtonAction(*iter));
|
||||||
tempButton->Appearance.BorderInactive = style::Colour::WarningTitle;
|
tempButton->Appearance.BorderInactive = style::Colour::WarningTitle;
|
||||||
@ -1934,9 +1933,9 @@ void GameView::NotifyZoomChanged(GameModel * sender)
|
|||||||
zoomEnabled = sender->GetZoomEnabled();
|
zoomEnabled = sender->GetZoomEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::NotifyLogChanged(GameModel * sender, string entry)
|
void GameView::NotifyLogChanged(GameModel * sender, String entry)
|
||||||
{
|
{
|
||||||
logEntries.push_front(std::pair<std::string, int>(entry, 600));
|
logEntries.push_front(std::pair<String, int>(entry, 600));
|
||||||
if (logEntries.size() > 20)
|
if (logEntries.size() > 20)
|
||||||
logEntries.pop_back();
|
logEntries.pop_back();
|
||||||
}
|
}
|
||||||
@ -2218,7 +2217,7 @@ void GameView::OnDraw()
|
|||||||
VideoBuffer screenshot(ren->DumpFrame());
|
VideoBuffer screenshot(ren->DumpFrame());
|
||||||
std::vector<char> data = format::VideoBufferToPNG(screenshot);
|
std::vector<char> data = format::VideoBufferToPNG(screenshot);
|
||||||
|
|
||||||
std::stringstream filename;
|
ByteString::Stream filename;
|
||||||
filename << "screenshot_";
|
filename << "screenshot_";
|
||||||
filename << std::setfill('0') << std::setw(6) << (screenshotIndex++);
|
filename << std::setfill('0') << std::setw(6) << (screenshotIndex++);
|
||||||
filename << ".png";
|
filename << ".png";
|
||||||
@ -2232,7 +2231,7 @@ void GameView::OnDraw()
|
|||||||
VideoBuffer screenshot(ren->DumpFrame());
|
VideoBuffer screenshot(ren->DumpFrame());
|
||||||
std::vector<char> data = format::VideoBufferToPPM(screenshot);
|
std::vector<char> data = format::VideoBufferToPPM(screenshot);
|
||||||
|
|
||||||
std::stringstream filename;
|
ByteString::Stream filename;
|
||||||
filename << "recordings" << PATH_SEP << recordingFolder << PATH_SEP;
|
filename << "recordings" << PATH_SEP << recordingFolder << PATH_SEP;
|
||||||
filename << "frame_";
|
filename << "frame_";
|
||||||
filename << std::setfill('0') << std::setw(6) << (recordingIndex++);
|
filename << std::setfill('0') << std::setw(6) << (recordingIndex++);
|
||||||
@ -2245,10 +2244,10 @@ void GameView::OnDraw()
|
|||||||
{
|
{
|
||||||
int startX = 20;
|
int startX = 20;
|
||||||
int startY = YRES-20;
|
int startY = YRES-20;
|
||||||
deque<std::pair<std::string, int> >::iterator iter;
|
deque<std::pair<String, int> >::iterator iter;
|
||||||
for(iter = logEntries.begin(); iter != logEntries.end(); iter++)
|
for(iter = logEntries.begin(); iter != logEntries.end(); iter++)
|
||||||
{
|
{
|
||||||
string message = (*iter).first;
|
String message = (*iter).first;
|
||||||
int alpha = std::min((*iter).second, 255);
|
int alpha = std::min((*iter).second, 255);
|
||||||
if (alpha <= 0) //erase this and everything older
|
if (alpha <= 0) //erase this and everything older
|
||||||
{
|
{
|
||||||
@ -2256,8 +2255,8 @@ void GameView::OnDraw()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
startY -= 14;
|
startY -= 14;
|
||||||
g->fillrect(startX-3, startY-3, Graphics::textwidth((char*)message.c_str())+6, 14, 0, 0, 0, 100);
|
g->fillrect(startX-3, startY-3, Graphics::textwidth(message)+6, 14, 0, 0, 0, 100);
|
||||||
g->drawtext(startX, startY, message.c_str(), 255, 255, 255, alpha);
|
g->drawtext(startX, startY, message, 255, 255, 255, alpha);
|
||||||
(*iter).second -= 3;
|
(*iter).second -= 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2265,13 +2264,13 @@ void GameView::OnDraw()
|
|||||||
|
|
||||||
if(recording)
|
if(recording)
|
||||||
{
|
{
|
||||||
std::stringstream sampleInfo;
|
String::Stream sampleInfo;
|
||||||
sampleInfo << recordingIndex;
|
sampleInfo << recordingIndex;
|
||||||
sampleInfo << ". \x8E REC";
|
sampleInfo << ". \x8E REC";
|
||||||
|
|
||||||
int textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str());
|
int textWidth = Graphics::textwidth(sampleInfo.str());
|
||||||
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);
|
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);
|
||||||
g->drawtext(XRES-16-textWidth, 16, (const char*)sampleInfo.str().c_str(), 255, 50, 20, 255);
|
g->drawtext(XRES-16-textWidth, 16, sampleInfo.str(), 255, 50, 20, 255);
|
||||||
}
|
}
|
||||||
else if(showHud)
|
else if(showHud)
|
||||||
{
|
{
|
||||||
@ -2281,7 +2280,7 @@ void GameView::OnDraw()
|
|||||||
alpha = 255-toolTipPresence*3;
|
alpha = 255-toolTipPresence*3;
|
||||||
if (alpha < 50)
|
if (alpha < 50)
|
||||||
alpha = 50;
|
alpha = 50;
|
||||||
std::stringstream sampleInfo;
|
String::Stream sampleInfo;
|
||||||
sampleInfo.precision(2);
|
sampleInfo.precision(2);
|
||||||
|
|
||||||
int type = sample.particle.type;
|
int type = sample.particle.type;
|
||||||
@ -2295,15 +2294,15 @@ void GameView::OnDraw()
|
|||||||
if (showDebug)
|
if (showDebug)
|
||||||
{
|
{
|
||||||
if (type == PT_LAVA && c->IsValidElement(ctype))
|
if (type == PT_LAVA && c->IsValidElement(ctype))
|
||||||
sampleInfo << "Molten " << c->ElementResolve(ctype, -1);
|
sampleInfo << "Molten " << c->ElementResolve(ctype, -1).FromAscii();
|
||||||
else if ((type == PT_PIPE || type == PT_PPIP) && c->IsValidElement(ctype))
|
else if ((type == PT_PIPE || type == PT_PPIP) && c->IsValidElement(ctype))
|
||||||
sampleInfo << c->ElementResolve(type, -1) << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]);
|
sampleInfo << c->ElementResolve(type, -1).FromAscii() << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]).FromAscii();
|
||||||
else if (type == PT_LIFE)
|
else if (type == PT_LIFE)
|
||||||
sampleInfo << c->ElementResolve(type, ctype);
|
sampleInfo << c->ElementResolve(type, ctype).FromAscii();
|
||||||
else if (type == PT_FILT)
|
else if (type == PT_FILT)
|
||||||
{
|
{
|
||||||
sampleInfo << c->ElementResolve(type, ctype);
|
sampleInfo << c->ElementResolve(type, ctype).FromAscii();
|
||||||
const char* filtModes[] = {"set colour", "AND", "OR", "subtract colour", "red shift", "blue shift", "no effect", "XOR", "NOT", "old QRTZ scattering", "variable red shift", "variable blue shift"};
|
String filtModes[] = {"set colour", "AND", "OR", "subtract colour", "red shift", "blue shift", "no effect", "XOR", "NOT", "old QRTZ scattering", "variable red shift", "variable blue shift"};
|
||||||
if (sample.particle.tmp>=0 && sample.particle.tmp<=11)
|
if (sample.particle.tmp>=0 && sample.particle.tmp<=11)
|
||||||
sampleInfo << " (" << filtModes[sample.particle.tmp] << ")";
|
sampleInfo << " (" << filtModes[sample.particle.tmp] << ")";
|
||||||
else
|
else
|
||||||
@ -2311,14 +2310,14 @@ void GameView::OnDraw()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sampleInfo << c->ElementResolve(type, ctype);
|
sampleInfo << c->ElementResolve(type, ctype).FromAscii();
|
||||||
if (wavelengthGfx)
|
if (wavelengthGfx)
|
||||||
sampleInfo << " (" << ctype << ")";
|
sampleInfo << " (" << ctype << ")";
|
||||||
// Some elements store extra LIFE info in upper bits of ctype, instead of tmp/tmp2
|
// Some elements store extra LIFE info in upper bits of ctype, instead of tmp/tmp2
|
||||||
else if (type == PT_CRAY || type == PT_DRAY || type == PT_CONV)
|
else if (type == PT_CRAY || type == PT_DRAY || type == PT_CONV)
|
||||||
sampleInfo << " (" << c->ElementResolve(TYP(ctype), ID(ctype)) << ")";
|
sampleInfo << " (" << c->ElementResolve(TYP(ctype), ID(ctype)).FromAscii() << ")";
|
||||||
else if (c->IsValidElement(ctype))
|
else if (c->IsValidElement(ctype))
|
||||||
sampleInfo << " (" << c->ElementResolve(ctype, -1) << ")";
|
sampleInfo << " (" << c->ElementResolve(ctype, -1).FromAscii() << ")";
|
||||||
else
|
else
|
||||||
sampleInfo << " ()";
|
sampleInfo << " ()";
|
||||||
}
|
}
|
||||||
@ -2336,13 +2335,13 @@ void GameView::OnDraw()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (type == PT_LAVA && c->IsValidElement(ctype))
|
if (type == PT_LAVA && c->IsValidElement(ctype))
|
||||||
sampleInfo << "Molten " << c->ElementResolve(ctype, -1);
|
sampleInfo << "Molten " << c->ElementResolve(ctype, -1).FromAscii();
|
||||||
else if ((type == PT_PIPE || type == PT_PPIP) && c->IsValidElement(ctype))
|
else if ((type == PT_PIPE || type == PT_PPIP) && c->IsValidElement(ctype))
|
||||||
sampleInfo << c->ElementResolve(type, -1) << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]);
|
sampleInfo << c->ElementResolve(type, -1).FromAscii() << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]).FromAscii();
|
||||||
else if (type == PT_LIFE)
|
else if (type == PT_LIFE)
|
||||||
sampleInfo << c->ElementResolve(type, ctype);
|
sampleInfo << c->ElementResolve(type, ctype).FromAscii();
|
||||||
else
|
else
|
||||||
sampleInfo << c->ElementResolve(type, ctype);
|
sampleInfo << c->ElementResolve(type, ctype).FromAscii();
|
||||||
sampleInfo << ", Temp: " << std::fixed << sample.particle.temp - 273.15f << " C";
|
sampleInfo << ", Temp: " << std::fixed << sample.particle.temp - 273.15f << " C";
|
||||||
sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
|
sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
|
||||||
}
|
}
|
||||||
@ -2361,9 +2360,9 @@ void GameView::OnDraw()
|
|||||||
sampleInfo << "Empty";
|
sampleInfo << "Empty";
|
||||||
}
|
}
|
||||||
|
|
||||||
int textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str());
|
int textWidth = Graphics::textwidth(sampleInfo.str());
|
||||||
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, alpha*0.5f);
|
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, alpha*0.5f);
|
||||||
g->drawtext(XRES-16-textWidth, 16, (const char*)sampleInfo.str().c_str(), 255, 255, 255, alpha*0.75f);
|
g->drawtext(XRES-16-textWidth, 16, sampleInfo.str(), 255, 255, 255, alpha*0.75f);
|
||||||
|
|
||||||
#ifndef OGLI
|
#ifndef OGLI
|
||||||
if (wavelengthGfx)
|
if (wavelengthGfx)
|
||||||
@ -2404,7 +2403,7 @@ void GameView::OnDraw()
|
|||||||
|
|
||||||
if (showDebug)
|
if (showDebug)
|
||||||
{
|
{
|
||||||
sampleInfo.str(std::string());
|
sampleInfo.str(String());
|
||||||
|
|
||||||
if (type)
|
if (type)
|
||||||
sampleInfo << "#" << sample.ParticleID << ", ";
|
sampleInfo << "#" << sample.ParticleID << ", ";
|
||||||
@ -2417,16 +2416,16 @@ void GameView::OnDraw()
|
|||||||
if (c->GetAHeatEnable())
|
if (c->GetAHeatEnable())
|
||||||
sampleInfo << ", AHeat: " << std::fixed << sample.AirTemperature -273.15f << " C";
|
sampleInfo << ", AHeat: " << std::fixed << sample.AirTemperature -273.15f << " C";
|
||||||
|
|
||||||
textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str());
|
textWidth = Graphics::textwidth(sampleInfo.str());
|
||||||
g->fillrect(XRES-20-textWidth, 27, textWidth+8, 14, 0, 0, 0, alpha*0.5f);
|
g->fillrect(XRES-20-textWidth, 27, textWidth+8, 14, 0, 0, 0, alpha*0.5f);
|
||||||
g->drawtext(XRES-16-textWidth, 30, (const char*)sampleInfo.str().c_str(), 255, 255, 255, alpha*0.75f);
|
g->drawtext(XRES-16-textWidth, 30, sampleInfo.str(), 255, 255, 255, alpha*0.75f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(showHud && introText < 51)
|
if(showHud && introText < 51)
|
||||||
{
|
{
|
||||||
//FPS and some version info
|
//FPS and some version info
|
||||||
std::stringstream fpsInfo;
|
String::Stream fpsInfo;
|
||||||
fpsInfo.precision(2);
|
fpsInfo.precision(2);
|
||||||
fpsInfo << "FPS: " << std::fixed << ui::Engine::Ref().GetFps();
|
fpsInfo << "FPS: " << std::fixed << ui::Engine::Ref().GetFps();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -2449,37 +2448,37 @@ void GameView::OnDraw()
|
|||||||
if (ren && ren->findingElement)
|
if (ren && ren->findingElement)
|
||||||
fpsInfo << " [FIND]";
|
fpsInfo << " [FIND]";
|
||||||
|
|
||||||
int textWidth = Graphics::textwidth((char*)fpsInfo.str().c_str());
|
int textWidth = Graphics::textwidth(fpsInfo.str());
|
||||||
int alpha = 255-introText*5;
|
int alpha = 255-introText*5;
|
||||||
g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, alpha*0.5);
|
g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, alpha*0.5);
|
||||||
g->drawtext(16, 16, (const char*)fpsInfo.str().c_str(), 32, 216, 255, alpha*0.75);
|
g->drawtext(16, 16, fpsInfo.str(), 32, 216, 255, alpha*0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Tooltips
|
//Tooltips
|
||||||
if(infoTipPresence)
|
if(infoTipPresence)
|
||||||
{
|
{
|
||||||
int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5;
|
int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5;
|
||||||
g->drawtext_outline((XRES-Graphics::textwidth((char*)infoTip.c_str()))/2, (YRES/2)-2, (char*)infoTip.c_str(), 255, 255, 255, infoTipAlpha);
|
g->drawtext_outline((XRES-Graphics::textwidth(infoTip))/2, (YRES/2)-2, infoTip, 255, 255, 255, infoTipAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(toolTipPresence && toolTipPosition.X!=-1 && toolTipPosition.Y!=-1 && toolTip.length())
|
if(toolTipPresence && toolTipPosition.X!=-1 && toolTipPosition.Y!=-1 && toolTip.length())
|
||||||
{
|
{
|
||||||
if (toolTipPosition.Y == Size.Y-MENUSIZE-10)
|
if (toolTipPosition.Y == Size.Y-MENUSIZE-10)
|
||||||
g->drawtext_outline(toolTipPosition.X, toolTipPosition.Y, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
|
g->drawtext_outline(toolTipPosition.X, toolTipPosition.Y, toolTip, 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
|
||||||
else
|
else
|
||||||
g->drawtext(toolTipPosition.X, toolTipPosition.Y, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
|
g->drawtext(toolTipPosition.X, toolTipPosition.Y, toolTip, 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(buttonTipShow > 0)
|
if(buttonTipShow > 0)
|
||||||
{
|
{
|
||||||
g->drawtext(16, Size.Y-MENUSIZE-24, (char*)buttonTip.c_str(), 255, 255, 255, buttonTipShow>51?255:buttonTipShow*5);
|
g->drawtext(16, Size.Y-MENUSIZE-24, buttonTip, 255, 255, 255, buttonTipShow>51?255:buttonTipShow*5);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Introduction text
|
//Introduction text
|
||||||
if(introText)
|
if(introText)
|
||||||
{
|
{
|
||||||
g->fillrect(0, 0, WINDOWW, WINDOWH, 0, 0, 0, introText>51?102:introText*2);
|
g->fillrect(0, 0, WINDOWW, WINDOWH, 0, 0, 0, introText>51?102:introText*2);
|
||||||
g->drawtext(16, 20, (char*)introTextMessage.c_str(), 255, 255, 255, introText>51?255:introText*5);
|
g->drawtext(16, 20, introTextMessage, 255, 255, 255, introText>51?255:introText*5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear menu areas, to ensure particle graphics don't overlap
|
// Clear menu areas, to ensure particle graphics don't overlap
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "GameController.h"
|
#include "GameController.h"
|
||||||
#include "GameModel.h"
|
#include "GameModel.h"
|
||||||
#include "gui/interface/Window.h"
|
#include "gui/interface/Window.h"
|
||||||
@ -54,16 +54,16 @@ private:
|
|||||||
int lastMenu;
|
int lastMenu;
|
||||||
|
|
||||||
int toolTipPresence;
|
int toolTipPresence;
|
||||||
std::string toolTip;
|
String toolTip;
|
||||||
bool isToolTipFadingIn;
|
bool isToolTipFadingIn;
|
||||||
ui::Point toolTipPosition;
|
ui::Point toolTipPosition;
|
||||||
int infoTipPresence;
|
int infoTipPresence;
|
||||||
std::string infoTip;
|
String infoTip;
|
||||||
int buttonTipShow;
|
int buttonTipShow;
|
||||||
std::string buttonTip;
|
String buttonTip;
|
||||||
bool isButtonTipFadingIn;
|
bool isButtonTipFadingIn;
|
||||||
int introText;
|
int introText;
|
||||||
std::string introTextMessage;
|
String introTextMessage;
|
||||||
|
|
||||||
bool doScreenshot;
|
bool doScreenshot;
|
||||||
int screenshotIndex;
|
int screenshotIndex;
|
||||||
@ -80,7 +80,7 @@ private:
|
|||||||
vector<ui::Button*> menuButtons;
|
vector<ui::Button*> menuButtons;
|
||||||
vector<ToolButton*> toolButtons;
|
vector<ToolButton*> toolButtons;
|
||||||
vector<ui::Component*> notificationComponents;
|
vector<ui::Component*> notificationComponents;
|
||||||
deque<std::pair<std::string, int> > logEntries;
|
deque<std::pair<String, int> > logEntries;
|
||||||
ui::Button * scrollBar;
|
ui::Button * scrollBar;
|
||||||
ui::Button * searchButton;
|
ui::Button * searchButton;
|
||||||
ui::Button * reloadButton;
|
ui::Button * reloadButton;
|
||||||
@ -178,14 +178,14 @@ public:
|
|||||||
void NotifyColourActivePresetChanged(GameModel * sender);
|
void NotifyColourActivePresetChanged(GameModel * sender);
|
||||||
void NotifyPlaceSaveChanged(GameModel * sender);
|
void NotifyPlaceSaveChanged(GameModel * sender);
|
||||||
void NotifyNotificationsChanged(GameModel * sender);
|
void NotifyNotificationsChanged(GameModel * sender);
|
||||||
void NotifyLogChanged(GameModel * sender, string entry);
|
void NotifyLogChanged(GameModel * sender, String entry);
|
||||||
void NotifyToolTipChanged(GameModel * sender);
|
void NotifyToolTipChanged(GameModel * sender);
|
||||||
void NotifyInfoTipChanged(GameModel * sender);
|
void NotifyInfoTipChanged(GameModel * sender);
|
||||||
void NotifyQuickOptionsChanged(GameModel * sender);
|
void NotifyQuickOptionsChanged(GameModel * sender);
|
||||||
void NotifyLastToolChanged(GameModel * sender);
|
void NotifyLastToolChanged(GameModel * sender);
|
||||||
|
|
||||||
|
|
||||||
virtual void ToolTip(ui::Point senderPosition, std::string toolTip);
|
virtual void ToolTip(ui::Point senderPosition, String toolTip);
|
||||||
|
|
||||||
virtual void OnMouseMove(int x, int y, int dx, int dy);
|
virtual void OnMouseMove(int x, int y, int dx, int dy);
|
||||||
virtual void OnMouseDown(int x, int y, unsigned button);
|
virtual void OnMouseDown(int x, int y, unsigned button);
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
#ifndef MENU_H_
|
#ifndef MENU_H_
|
||||||
#define MENU_H_
|
#define MENU_H_
|
||||||
|
|
||||||
|
#include "common/String.h"
|
||||||
#include "Tool.h"
|
#include "Tool.h"
|
||||||
|
|
||||||
class Menu
|
class Menu
|
||||||
{
|
{
|
||||||
char icon;
|
String::value_type icon;
|
||||||
string description;
|
String description;
|
||||||
vector<Tool*> tools;
|
std::vector<Tool*> tools;
|
||||||
bool visible;
|
bool visible;
|
||||||
public:
|
public:
|
||||||
Menu(char icon_, string description_, int visible_):
|
Menu(String::value_type icon_, String description_, int visible_):
|
||||||
icon(icon_),
|
icon(icon_),
|
||||||
description(description_),
|
description(description_),
|
||||||
tools(vector<Tool*>()),
|
tools(std::vector<Tool*>()),
|
||||||
visible(visible_ ? true : false)
|
visible(visible_ ? true : false)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -28,17 +29,17 @@ public:
|
|||||||
tools.clear();
|
tools.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Tool*> GetToolList()
|
std::vector<Tool*> GetToolList()
|
||||||
{
|
{
|
||||||
return tools;
|
return tools;
|
||||||
}
|
}
|
||||||
|
|
||||||
char GetIcon()
|
String::value_type GetIcon()
|
||||||
{
|
{
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetDescription()
|
String GetDescription()
|
||||||
{
|
{
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#ifndef NOTIFICATION_H_
|
#ifndef NOTIFICATION_H_
|
||||||
#define NOTIFICATION_H_
|
#define NOTIFICATION_H_
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
|
|
||||||
class Notification
|
class Notification
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Notification(std::string message) : Message(message) {}
|
Notification(String message) : Message(message) {}
|
||||||
virtual ~Notification() {};
|
virtual ~Notification() {};
|
||||||
std::string Message;
|
String Message;
|
||||||
|
|
||||||
virtual void Action() { }
|
virtual void Action() { }
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
|
||||||
#include "Tool.h"
|
#include "Tool.h"
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include "gui/Style.h"
|
#include "gui/Style.h"
|
||||||
@ -69,7 +68,7 @@ sim(sim_)
|
|||||||
PropertyWindow * w;
|
PropertyWindow * w;
|
||||||
public:
|
public:
|
||||||
PropertyChanged(PropertyWindow * w): w(w) { }
|
PropertyChanged(PropertyWindow * w): w(w) { }
|
||||||
virtual void OptionChanged(ui::DropDown * sender, std::pair<std::string, int> option)
|
virtual void OptionChanged(ui::DropDown * sender, std::pair<String, int> option)
|
||||||
{
|
{
|
||||||
w->FocusComponent(w->textField);
|
w->FocusComponent(w->textField);
|
||||||
}
|
}
|
||||||
@ -79,7 +78,7 @@ sim(sim_)
|
|||||||
AddComponent(property);
|
AddComponent(property);
|
||||||
for (size_t i = 0; i < properties.size(); i++)
|
for (size_t i = 0; i < properties.size(); i++)
|
||||||
{
|
{
|
||||||
property->AddOption(std::pair<std::string, int>(properties[i].Name, i));
|
property->AddOption(std::pair<String, int>(properties[i].Name.FromAscii(), i));
|
||||||
}
|
}
|
||||||
property->SetOption(Client::Ref().GetPrefInteger("Prop.Type", 0));
|
property->SetOption(Client::Ref().GetPrefInteger("Prop.Type", 0));
|
||||||
|
|
||||||
@ -97,7 +96,7 @@ void PropertyWindow::SetProperty()
|
|||||||
{
|
{
|
||||||
if(property->GetOption().second!=-1 && textField->GetText().length() > 0)
|
if(property->GetOption().second!=-1 && textField->GetText().length() > 0)
|
||||||
{
|
{
|
||||||
std::string value = textField->GetText();
|
String value = textField->GetText();
|
||||||
try {
|
try {
|
||||||
switch(properties[property->GetOption().second].Type)
|
switch(properties[property->GetOption().second].Type)
|
||||||
{
|
{
|
||||||
@ -108,23 +107,23 @@ void PropertyWindow::SetProperty()
|
|||||||
if(value.length() > 2 && value.substr(0, 2) == "0x")
|
if(value.length() > 2 && value.substr(0, 2) == "0x")
|
||||||
{
|
{
|
||||||
//0xC0FFEE
|
//0xC0FFEE
|
||||||
std::stringstream buffer;
|
String::Stream buffer;
|
||||||
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
|
buffer.exceptions(String::Stream::failbit | String::Stream::badbit);
|
||||||
buffer << std::hex << value.substr(2);
|
buffer << std::hex << value.substr(2);
|
||||||
buffer >> v;
|
buffer >> v;
|
||||||
}
|
}
|
||||||
else if(value.length() > 1 && value[0] == '#')
|
else if(value.length() > 1 && value[0] == '#')
|
||||||
{
|
{
|
||||||
//#C0FFEE
|
//#C0FFEE
|
||||||
std::stringstream buffer;
|
String::Stream buffer;
|
||||||
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
|
buffer.exceptions(String::Stream::failbit | String::Stream::badbit);
|
||||||
buffer << std::hex << value.substr(1);
|
buffer << std::hex << value.substr(1);
|
||||||
buffer >> v;
|
buffer >> v;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
if (properties[property->GetOption().second].Type == StructProperty::ParticleType && (type = sim->GetParticleType(value)) != -1)
|
if (properties[property->GetOption().second].Type == StructProperty::ParticleType && (type = sim->GetParticleType(value.ToUtf8())) != -1)
|
||||||
{
|
{
|
||||||
v = type;
|
v = type;
|
||||||
|
|
||||||
@ -134,8 +133,8 @@ void PropertyWindow::SetProperty()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::stringstream buffer(value);
|
String::Stream buffer(value);
|
||||||
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
|
buffer.exceptions(String::Stream::failbit | String::Stream::badbit);
|
||||||
buffer >> v;
|
buffer >> v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,23 +158,23 @@ void PropertyWindow::SetProperty()
|
|||||||
if(value.length() > 2 && value.substr(0, 2) == "0x")
|
if(value.length() > 2 && value.substr(0, 2) == "0x")
|
||||||
{
|
{
|
||||||
//0xC0FFEE
|
//0xC0FFEE
|
||||||
std::stringstream buffer;
|
String::Stream buffer;
|
||||||
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
|
buffer.exceptions(String::Stream::failbit | String::Stream::badbit);
|
||||||
buffer << std::hex << value.substr(2);
|
buffer << std::hex << value.substr(2);
|
||||||
buffer >> v;
|
buffer >> v;
|
||||||
}
|
}
|
||||||
else if(value.length() > 1 && value[0] == '#')
|
else if(value.length() > 1 && value[0] == '#')
|
||||||
{
|
{
|
||||||
//#C0FFEE
|
//#C0FFEE
|
||||||
std::stringstream buffer;
|
String::Stream buffer;
|
||||||
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
|
buffer.exceptions(String::Stream::failbit | String::Stream::badbit);
|
||||||
buffer << std::hex << value.substr(1);
|
buffer << std::hex << value.substr(1);
|
||||||
buffer >> v;
|
buffer >> v;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::stringstream buffer(value);
|
String::Stream buffer(value);
|
||||||
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
|
buffer.exceptions(String::Stream::failbit | String::Stream::badbit);
|
||||||
buffer >> v;
|
buffer >> v;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -186,8 +185,8 @@ void PropertyWindow::SetProperty()
|
|||||||
}
|
}
|
||||||
case StructProperty::Float:
|
case StructProperty::Float:
|
||||||
{
|
{
|
||||||
std::stringstream buffer(value);
|
String::Stream buffer(value);
|
||||||
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
|
buffer.exceptions(String::Stream::failbit | String::Stream::badbit);
|
||||||
buffer >> tool->propValue.Float;
|
buffer >> tool->propValue.Float;
|
||||||
if (properties[property->GetOption().second].Name == "temp" && value.length())
|
if (properties[property->GetOption().second].Name == "temp" && value.length())
|
||||||
{
|
{
|
||||||
@ -212,7 +211,7 @@ void PropertyWindow::SetProperty()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Client::Ref().SetPref("Prop.Type", property->GetOption().second);
|
Client::Ref().SetPref("Prop.Type", property->GetOption().second);
|
||||||
Client::Ref().SetPref("Prop.Value", textField->GetText());
|
Client::Ref().SetPrefUnicode("Prop.Value", textField->GetText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class GameModel;
|
class GameModel;
|
||||||
@ -23,9 +23,9 @@ protected:
|
|||||||
std::vector<QuickOptionListener*> listeners;
|
std::vector<QuickOptionListener*> listeners;
|
||||||
GameModel * m;
|
GameModel * m;
|
||||||
Type type;
|
Type type;
|
||||||
std::string icon;
|
String icon;
|
||||||
std::string description;
|
String description;
|
||||||
QuickOption(std::string icon, std::string description, GameModel * m, Type type) :
|
QuickOption(String icon, String description, GameModel * m, Type type) :
|
||||||
m(m),
|
m(m),
|
||||||
type(type),
|
type(type),
|
||||||
icon(icon),
|
icon(icon),
|
||||||
@ -57,10 +57,10 @@ public:
|
|||||||
virtual int GetMutli() { return 0;}
|
virtual int GetMutli() { return 0;}
|
||||||
virtual int GetMultiCount() { return 0;}
|
virtual int GetMultiCount() { return 0;}
|
||||||
|
|
||||||
std::string GetIcon() { return icon; }
|
String GetIcon() { return icon; }
|
||||||
void SetIcon(std::string icon) { this->icon = icon; }
|
void SetIcon(String icon) { this->icon = icon; }
|
||||||
std::string GetDescription() { return description; }
|
String GetDescription() { return description; }
|
||||||
void SetDescription(std::string description) { this->description = description; }
|
void SetDescription(String description) { this->description = description; }
|
||||||
void Perform()
|
void Perform()
|
||||||
{
|
{
|
||||||
perform();
|
perform();
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
class RenderPreset
|
class RenderPreset
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string Name;
|
String Name;
|
||||||
std::vector<unsigned int> RenderModes;
|
std::vector<unsigned int> RenderModes;
|
||||||
std::vector<unsigned int> DisplayModes;
|
std::vector<unsigned int> DisplayModes;
|
||||||
unsigned int ColourMode;
|
unsigned int ColourMode;
|
||||||
|
|
||||||
RenderPreset(): Name(""), ColourMode(0) {}
|
RenderPreset(): Name(""), ColourMode(0) {}
|
||||||
RenderPreset(std::string name, std::vector<unsigned int> renderModes, std::vector<unsigned int> displayModes, unsigned int colourMode):
|
RenderPreset(String name, std::vector<unsigned int> renderModes, std::vector<unsigned int> displayModes, unsigned int colourMode):
|
||||||
Name(name),
|
Name(name),
|
||||||
RenderModes(renderModes),
|
RenderModes(renderModes),
|
||||||
DisplayModes(displayModes),
|
DisplayModes(displayModes),
|
||||||
|
@ -128,10 +128,10 @@ SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Poi
|
|||||||
|
|
||||||
justification = new ui::DropDown(ui::Point(52, 48), ui::Point(50, 16));
|
justification = new ui::DropDown(ui::Point(52, 48), ui::Point(50, 16));
|
||||||
AddComponent(justification);
|
AddComponent(justification);
|
||||||
justification->AddOption(std::pair<std::string, int>("\xA0 Left", (int)sign::Left));
|
justification->AddOption(std::pair<String, int>("\xA0 Left", (int)sign::Left));
|
||||||
justification->AddOption(std::pair<std::string, int>("\x9E Middle", (int)sign::Middle));
|
justification->AddOption(std::pair<String, int>("\x9E Middle", (int)sign::Middle));
|
||||||
justification->AddOption(std::pair<std::string, int>("\x9F Right", (int)sign::Right));
|
justification->AddOption(std::pair<String, int>("\x9F Right", (int)sign::Right));
|
||||||
justification->AddOption(std::pair<std::string, int>("\x9D None", (int)sign::None));
|
justification->AddOption(std::pair<String, int>("\x9D None", (int)sign::None));
|
||||||
justification->SetOption(1);
|
justification->SetOption(1);
|
||||||
justification->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
justification->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||||
|
|
||||||
@ -181,9 +181,9 @@ void SignWindow::DoDraw()
|
|||||||
{
|
{
|
||||||
sign & currentSign = *iter;
|
sign & currentSign = *iter;
|
||||||
int x, y, w, h, dx, dy;
|
int x, y, w, h, dx, dy;
|
||||||
char type = 0;
|
String::value_type type = 0;
|
||||||
Graphics * g = GetGraphics();
|
Graphics * g = GetGraphics();
|
||||||
std::string text = currentSign.getText(sim);
|
String text = currentSign.getText(sim);
|
||||||
sign::splitsign(currentSign.text, &type);
|
sign::splitsign(currentSign.text, &type);
|
||||||
currentSign.pos(text, x, y, w, h);
|
currentSign.pos(text, x, y, w, h);
|
||||||
g->clearrect(x, y, w+1, h);
|
g->clearrect(x, y, w+1, h);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "Tool.h"
|
#include "Tool.h"
|
||||||
#include "gui/game/Brush.h"
|
#include "gui/game/Brush.h"
|
||||||
|
|
||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Tool::Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
Tool::Tool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
||||||
textureGen(textureGen),
|
textureGen(textureGen),
|
||||||
toolID(id),
|
toolID(id),
|
||||||
toolName(name),
|
toolName(name),
|
||||||
@ -32,9 +32,9 @@ void Tool::SetTextureGen(VideoBuffer * (*textureGen)(int, int, int))
|
|||||||
{
|
{
|
||||||
this->textureGen = textureGen;
|
this->textureGen = textureGen;
|
||||||
}
|
}
|
||||||
std::string Tool::GetIdentifier() { return identifier; }
|
ByteString Tool::GetIdentifier() { return identifier; }
|
||||||
string Tool::GetName() { return toolName; }
|
ByteString Tool::GetName() { return toolName; }
|
||||||
string Tool::GetDescription() { return toolDescription; }
|
String Tool::GetDescription() { return toolDescription; }
|
||||||
Tool::~Tool() {}
|
Tool::~Tool() {}
|
||||||
|
|
||||||
void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { }
|
void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
@ -50,7 +50,7 @@ void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Po
|
|||||||
void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {}
|
void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {}
|
||||||
|
|
||||||
|
|
||||||
ElementTool::ElementTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
ElementTool::ElementTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
||||||
Tool(id, name, description, r, g, b, identifier, textureGen)
|
Tool(id, name, description, r, g, b, identifier, textureGen)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ void ElementTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WallTool::WallTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
WallTool::WallTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
||||||
Tool(id, name, description, r, g, b, identifier, textureGen)
|
Tool(id, name, description, r, g, b, identifier, textureGen)
|
||||||
{
|
{
|
||||||
blocky = true;
|
blocky = true;
|
||||||
@ -110,7 +110,7 @@ void WallTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
|
|||||||
sim->FloodWalls(position.X, position.Y, toolID, -1);
|
sim->FloodWalls(position.X, position.Y, toolID, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
WindTool::WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
WindTool::WindTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
||||||
Tool(id, name, description, r, g, b, identifier, textureGen)
|
Tool(id, name, description, r, g, b, identifier, textureGen)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
#include "common/String.h"
|
||||||
|
|
||||||
#include "gui/interface/Point.h"
|
#include "gui/interface/Point.h"
|
||||||
#include "simulation/StructProperty.h"
|
#include "simulation/StructProperty.h"
|
||||||
|
|
||||||
@ -17,19 +16,19 @@ class Tool
|
|||||||
protected:
|
protected:
|
||||||
VideoBuffer * (*textureGen)(int, int, int);
|
VideoBuffer * (*textureGen)(int, int, int);
|
||||||
int toolID;
|
int toolID;
|
||||||
string toolName;
|
ByteString toolName;
|
||||||
string toolDescription;
|
String toolDescription;
|
||||||
float strength;
|
float strength;
|
||||||
bool blocky;
|
bool blocky;
|
||||||
std::string identifier;
|
ByteString identifier;
|
||||||
public:
|
public:
|
||||||
int colRed, colGreen, colBlue;
|
int colRed, colGreen, colBlue;
|
||||||
|
|
||||||
Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
Tool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
||||||
int GetToolID() { return toolID; }
|
int GetToolID() { return toolID; }
|
||||||
string GetName();
|
ByteString GetName();
|
||||||
string GetDescription();
|
String GetDescription();
|
||||||
std::string GetIdentifier();
|
ByteString GetIdentifier();
|
||||||
int GetBlocky() { return blocky; }
|
int GetBlocky() { return blocky; }
|
||||||
void SetStrength(float value) { strength = value; }
|
void SetStrength(float value) { strength = value; }
|
||||||
float GetStrength() { return strength; }
|
float GetStrength() { return strength; }
|
||||||
@ -106,7 +105,7 @@ public:
|
|||||||
class ElementTool: public Tool
|
class ElementTool: public Tool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ElementTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
ElementTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
||||||
virtual ~ElementTool();
|
virtual ~ElementTool();
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
|
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
|
||||||
@ -117,7 +116,7 @@ public:
|
|||||||
class Element_LIGH_Tool: public ElementTool
|
class Element_LIGH_Tool: public ElementTool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Element_LIGH_Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
Element_LIGH_Tool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
||||||
ElementTool(id, name, description, r, g, b, identifier, textureGen)
|
ElementTool(id, name, description, r, g, b, identifier, textureGen)
|
||||||
{ }
|
{ }
|
||||||
virtual ~Element_LIGH_Tool() { }
|
virtual ~Element_LIGH_Tool() { }
|
||||||
@ -130,7 +129,7 @@ public:
|
|||||||
class Element_TESC_Tool: public ElementTool
|
class Element_TESC_Tool: public ElementTool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Element_TESC_Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
Element_TESC_Tool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
||||||
ElementTool(id, name, description, r, g, b, identifier, textureGen)
|
ElementTool(id, name, description, r, g, b, identifier, textureGen)
|
||||||
{ }
|
{ }
|
||||||
virtual ~Element_TESC_Tool() {}
|
virtual ~Element_TESC_Tool() {}
|
||||||
@ -141,7 +140,7 @@ public:
|
|||||||
class PlopTool: public ElementTool
|
class PlopTool: public ElementTool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlopTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
PlopTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
||||||
ElementTool(id, name, description, r, g, b, identifier, textureGen)
|
ElementTool(id, name, description, r, g, b, identifier, textureGen)
|
||||||
{ }
|
{ }
|
||||||
virtual ~PlopTool() { }
|
virtual ~PlopTool() { }
|
||||||
@ -155,7 +154,7 @@ public:
|
|||||||
class WallTool: public Tool
|
class WallTool: public Tool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WallTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
WallTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
||||||
virtual ~WallTool();
|
virtual ~WallTool();
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
|
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
|
||||||
@ -166,7 +165,7 @@ public:
|
|||||||
class WindTool: public Tool
|
class WindTool: public Tool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
WindTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
||||||
virtual ~WindTool() { }
|
virtual ~WindTool() { }
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) { }
|
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
|
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include "gui/interface/Mouse.h"
|
#include "gui/interface/Mouse.h"
|
||||||
#include "Favorite.h"
|
#include "Favorite.h"
|
||||||
|
|
||||||
ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolIdentifier, std::string toolTip):
|
ToolButton::ToolButton(ui::Point position, ui::Point size, ByteString text_, ByteString toolIdentifier, String toolTip):
|
||||||
ui::Button(position, size, text_, toolTip),
|
ui::Button(position, size, text_.FromAscii(), toolTip),
|
||||||
toolIdentifier(toolIdentifier)
|
toolIdentifier(toolIdentifier)
|
||||||
{
|
{
|
||||||
SetSelectionState(-1);
|
SetSelectionState(-1);
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
class ToolButton: public ui::Button
|
class ToolButton: public ui::Button
|
||||||
{
|
{
|
||||||
int currentSelection;
|
int currentSelection;
|
||||||
std::string toolIdentifier;
|
ByteString toolIdentifier;
|
||||||
public:
|
public:
|
||||||
ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolIdentifier, std::string toolTip = "");
|
ToolButton(ui::Point position, ui::Point size, ByteString text_, ByteString toolIdentifier, String toolTip = "");
|
||||||
virtual void OnMouseUnclick(int x, int y, unsigned int button);
|
virtual void OnMouseUnclick(int x, int y, unsigned int button);
|
||||||
virtual void OnMouseUp(int x, int y, unsigned int button);
|
virtual void OnMouseUp(int x, int y, unsigned int button);
|
||||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
AvatarButton::AvatarButton(Point position, Point size, std::string username):
|
AvatarButton::AvatarButton(Point position, Point size, ByteString username):
|
||||||
Component(position, size),
|
Component(position, size),
|
||||||
avatar(NULL),
|
avatar(NULL),
|
||||||
name(username),
|
name(username),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef AVATARBUTTON_H_
|
#ifndef AVATARBUTTON_H_
|
||||||
#define AVATARBUTTON_H_
|
#define AVATARBUTTON_H_
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
|
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
@ -21,10 +21,10 @@ public:
|
|||||||
class AvatarButton : public Component, public RequestListener
|
class AvatarButton : public Component, public RequestListener
|
||||||
{
|
{
|
||||||
VideoBuffer * avatar;
|
VideoBuffer * avatar;
|
||||||
std::string name;
|
ByteString name;
|
||||||
bool tried;
|
bool tried;
|
||||||
public:
|
public:
|
||||||
AvatarButton(Point position, Point size, std::string username);
|
AvatarButton(Point position, Point size, ByteString username);
|
||||||
virtual ~AvatarButton();
|
virtual ~AvatarButton();
|
||||||
|
|
||||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||||
@ -42,8 +42,8 @@ public:
|
|||||||
|
|
||||||
virtual void DoAction();
|
virtual void DoAction();
|
||||||
|
|
||||||
void SetUsername(std::string username) { name = username; }
|
void SetUsername(ByteString username) { name = username; }
|
||||||
std::string GetUsername() { return name; }
|
ByteString GetUsername() { return name; }
|
||||||
void SetActionCallback(AvatarButtonAction * action);
|
void SetActionCallback(AvatarButtonAction * action);
|
||||||
protected:
|
protected:
|
||||||
bool isMouseInside, isButtonDown;
|
bool isMouseInside, isButtonDown;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
Button::Button(Point position, Point size, std::string buttonText, std::string toolTip):
|
Button::Button(Point position, Point size, String buttonText, String toolTip):
|
||||||
Component(position, size),
|
Component(position, size),
|
||||||
ButtonText(buttonText),
|
ButtonText(buttonText),
|
||||||
toolTip(toolTip),
|
toolTip(toolTip),
|
||||||
@ -19,14 +19,14 @@ Button::Button(Point position, Point size, std::string buttonText, std::string t
|
|||||||
TextPosition(ButtonText);
|
TextPosition(ButtonText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::TextPosition(std::string ButtonText)
|
void Button::TextPosition(String ButtonText)
|
||||||
{
|
{
|
||||||
buttonDisplayText = ButtonText;
|
buttonDisplayText = ButtonText;
|
||||||
if(buttonDisplayText.length())
|
if(buttonDisplayText.length())
|
||||||
{
|
{
|
||||||
if(Graphics::textwidth((char *)buttonDisplayText.c_str()) > Size.X - (Appearance.icon? 22 : 0))
|
if(Graphics::textwidth(buttonDisplayText) > Size.X - (Appearance.icon? 22 : 0))
|
||||||
{
|
{
|
||||||
int position = Graphics::textwidthx((char *)buttonDisplayText.c_str(), Size.X - (Appearance.icon? 38 : 22));
|
int position = Graphics::textwidthx(buttonDisplayText, Size.X - (Appearance.icon? 38 : 22));
|
||||||
buttonDisplayText = buttonDisplayText.erase(position, buttonDisplayText.length()-position);
|
buttonDisplayText = buttonDisplayText.erase(position, buttonDisplayText.length()-position);
|
||||||
buttonDisplayText += "...";
|
buttonDisplayText += "...";
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ void Button::SetIcon(Icon icon)
|
|||||||
TextPosition(ButtonText);
|
TextPosition(ButtonText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::SetText(std::string buttonText)
|
void Button::SetText(String buttonText)
|
||||||
{
|
{
|
||||||
ButtonText = buttonText;
|
ButtonText = buttonText;
|
||||||
TextPosition(ButtonText);
|
TextPosition(ButtonText);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef BUTTON_H_
|
#ifndef BUTTON_H_
|
||||||
#define BUTTON_H_
|
#define BUTTON_H_
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "Misc.h"
|
#include "Misc.h"
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include "Colour.h"
|
#include "Colour.h"
|
||||||
@ -21,7 +21,7 @@ public:
|
|||||||
class Button : public Component
|
class Button : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Button(Point position = Point(0, 0), Point size = Point(0, 0), std::string buttonText = "", std::string toolTip = "");
|
Button(Point position = Point(0, 0), Point size = Point(0, 0), String buttonText = "", String toolTip = "");
|
||||||
virtual ~Button();
|
virtual ~Button();
|
||||||
|
|
||||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||||
@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
virtual void Draw(const Point& screenPos);
|
virtual void Draw(const Point& screenPos);
|
||||||
|
|
||||||
virtual void TextPosition(std::string);
|
virtual void TextPosition(String);
|
||||||
inline bool GetState() { return state; }
|
inline bool GetState() { return state; }
|
||||||
virtual void DoAction(); //action of button what ever it may be
|
virtual void DoAction(); //action of button what ever it may be
|
||||||
virtual void DoAltAction(); //action of button what ever it may be
|
virtual void DoAltAction(); //action of button what ever it may be
|
||||||
@ -44,15 +44,15 @@ public:
|
|||||||
void SetToggleState(bool state);
|
void SetToggleState(bool state);
|
||||||
void SetActionCallback(ButtonAction * action);
|
void SetActionCallback(ButtonAction * action);
|
||||||
ButtonAction * GetActionCallback() { return actionCallback; }
|
ButtonAction * GetActionCallback() { return actionCallback; }
|
||||||
void SetText(std::string buttonText);
|
void SetText(String buttonText);
|
||||||
void SetIcon(Icon icon);
|
void SetIcon(Icon icon);
|
||||||
inline std::string GetText() { return ButtonText; }
|
inline String GetText() { return ButtonText; }
|
||||||
void SetToolTip(std::string newToolTip) { toolTip = newToolTip; }
|
void SetToolTip(String newToolTip) { toolTip = newToolTip; }
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std::string ButtonText;
|
String ButtonText;
|
||||||
std::string toolTip;
|
String toolTip;
|
||||||
std::string buttonDisplayText;
|
String buttonDisplayText;
|
||||||
|
|
||||||
bool isButtonDown, isAltButtonDown, state, isMouseInside, isTogglable, toggle;
|
bool isButtonDown, isAltButtonDown, state, isMouseInside, isTogglable, toggle;
|
||||||
ButtonAction * actionCallback;
|
ButtonAction * actionCallback;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
Checkbox::Checkbox(ui::Point position, ui::Point size, std::string text, std::string toolTip):
|
Checkbox::Checkbox(ui::Point position, ui::Point size, String text, String toolTip):
|
||||||
Component(position, size),
|
Component(position, size),
|
||||||
text(text),
|
text(text),
|
||||||
toolTip(toolTip),
|
toolTip(toolTip),
|
||||||
@ -15,12 +15,12 @@ Checkbox::Checkbox(ui::Point position, ui::Point size, std::string text, std::st
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Checkbox::SetText(std::string text)
|
void Checkbox::SetText(String text)
|
||||||
{
|
{
|
||||||
this->text = text;
|
this->text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Checkbox::GetText()
|
String Checkbox::GetText()
|
||||||
{
|
{
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef CHECKBOX_H_
|
#ifndef CHECKBOX_H_
|
||||||
#define CHECKBOX_H_
|
#define CHECKBOX_H_
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
@ -13,15 +13,15 @@ public:
|
|||||||
virtual ~CheckboxAction() {}
|
virtual ~CheckboxAction() {}
|
||||||
};
|
};
|
||||||
class Checkbox: public ui::Component {
|
class Checkbox: public ui::Component {
|
||||||
std::string text;
|
String text;
|
||||||
std::string toolTip;
|
String toolTip;
|
||||||
bool checked;
|
bool checked;
|
||||||
bool isMouseOver;
|
bool isMouseOver;
|
||||||
CheckboxAction * actionCallback;
|
CheckboxAction * actionCallback;
|
||||||
public:
|
public:
|
||||||
Checkbox(ui::Point position, ui::Point size, std::string text, std::string toolTip);
|
Checkbox(ui::Point position, ui::Point size, String text, String toolTip);
|
||||||
void SetText(std::string text);
|
void SetText(String text);
|
||||||
std::string GetText();
|
String GetText();
|
||||||
void SetIcon(Icon icon);
|
void SetIcon(Icon icon);
|
||||||
void Draw(const Point& screenPos);
|
void Draw(const Point& screenPos);
|
||||||
virtual void OnMouseEnter(int x, int y);
|
virtual void OnMouseEnter(int x, int y);
|
||||||
|
@ -62,13 +62,13 @@ void Component::Refresh()
|
|||||||
drawn = false;
|
drawn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Component::TextPosition(std::string displayText)
|
void Component::TextPosition(String displayText)
|
||||||
{
|
{
|
||||||
|
|
||||||
textPosition = ui::Point(0, 0);
|
textPosition = ui::Point(0, 0);
|
||||||
|
|
||||||
int textWidth, textHeight = 10;
|
int textWidth, textHeight = 10;
|
||||||
Graphics::textsize((char*)displayText.c_str(), textWidth, textHeight);
|
Graphics::textsize(displayText, textWidth, textHeight);
|
||||||
textSize.X = textWidth; textSize.Y = textHeight;
|
textSize.X = textWidth; textSize.Y = textHeight;
|
||||||
textHeight-=3;
|
textHeight-=3;
|
||||||
textWidth-=1;
|
textWidth-=1;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include "common/String.h"
|
||||||
#include "common/tpt-compat.h"
|
#include "common/tpt-compat.h"
|
||||||
#include "Appearance.h"
|
#include "Appearance.h"
|
||||||
#include "Point.h"
|
#include "Point.h"
|
||||||
@ -49,7 +49,7 @@ namespace ui
|
|||||||
ui::Appearance Appearance;
|
ui::Appearance Appearance;
|
||||||
//virtual void SetAppearance(ui::Appearance);
|
//virtual void SetAppearance(ui::Appearance);
|
||||||
//ui::Appearance GetAppearance();
|
//ui::Appearance GetAppearance();
|
||||||
virtual void TextPosition(std::string);
|
virtual void TextPosition(String);
|
||||||
|
|
||||||
void Refresh();
|
void Refresh();
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void ContextMenu::OnMouseDown(int x, int y, unsigned button)
|
|||||||
CloseActiveWindow();
|
CloseActiveWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextMenu::SetItem(int id, std::string text)
|
void ContextMenu::SetItem(int id, String text)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < items.size(); i++)
|
for (size_t i = 0; i < items.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ class ContextMenuItem
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int ID;
|
int ID;
|
||||||
std::string Text;
|
String Text;
|
||||||
bool Enabled;
|
bool Enabled;
|
||||||
ContextMenuItem(std::string text, int id, bool enabled) : ID(id), Text(text), Enabled(enabled) {}
|
ContextMenuItem(String text, int id, bool enabled) : ID(id), Text(text), Enabled(enabled) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ContextMenu: public ui::Window, public ButtonAction {
|
class ContextMenu: public ui::Window, public ButtonAction {
|
||||||
@ -28,7 +28,7 @@ public:
|
|||||||
virtual void ActionCallbackItem(ui::Button *sender, int item);
|
virtual void ActionCallbackItem(ui::Button *sender, int item);
|
||||||
virtual void AddItem(ContextMenuItem item);
|
virtual void AddItem(ContextMenuItem item);
|
||||||
virtual void RemoveItem(int id);
|
virtual void RemoveItem(int id);
|
||||||
virtual void SetItem(int id, std::string text);
|
virtual void SetItem(int id, String text);
|
||||||
virtual void Show(ui::Point position);
|
virtual void Show(ui::Point position);
|
||||||
virtual void OnDraw();
|
virtual void OnDraw();
|
||||||
virtual void OnMouseDown(int x, int y, unsigned button);
|
virtual void OnMouseDown(int x, int y, unsigned button);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
CopyTextButton::CopyTextButton(Point position, Point size, std::string buttonText, Label *copyTextLabel_):
|
CopyTextButton::CopyTextButton(Point position, Point size, String buttonText, Label *copyTextLabel_):
|
||||||
Button(position, size, buttonText)
|
Button(position, size, buttonText)
|
||||||
{
|
{
|
||||||
copyTextLabel = copyTextLabel_;
|
copyTextLabel = copyTextLabel_;
|
||||||
@ -20,7 +20,7 @@ namespace ui
|
|||||||
void CopyTextButton::OnMouseClick(int x, int y, unsigned int button)
|
void CopyTextButton::OnMouseClick(int x, int y, unsigned int button)
|
||||||
{
|
{
|
||||||
ui::Button::OnMouseClick(x, y, button);
|
ui::Button::OnMouseClick(x, y, button);
|
||||||
ClipboardPush(ButtonText);
|
ClipboardPush(ButtonText.ToUtf8());
|
||||||
|
|
||||||
copyTextLabel->SetText("Copied!");
|
copyTextLabel->SetText("Copied!");
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class CopyTextButton : public Button
|
|||||||
{
|
{
|
||||||
ui::Label *copyTextLabel;
|
ui::Label *copyTextLabel;
|
||||||
public:
|
public:
|
||||||
CopyTextButton(Point position, Point size, std::string buttonText, Label *copyTextLabel_);
|
CopyTextButton(Point position, Point size, String buttonText, Label *copyTextLabel_);
|
||||||
|
|
||||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ public:
|
|||||||
class ItemSelectedAction: public ButtonAction
|
class ItemSelectedAction: public ButtonAction
|
||||||
{
|
{
|
||||||
DropDownWindow * window;
|
DropDownWindow * window;
|
||||||
std::string option;
|
String option;
|
||||||
public:
|
public:
|
||||||
ItemSelectedAction(DropDownWindow * window, std::string option): window(window), option(option) { }
|
ItemSelectedAction(DropDownWindow * window, String option): window(window), option(option) { }
|
||||||
virtual void ActionCallback(ui::Button *sender)
|
virtual void ActionCallback(ui::Button *sender)
|
||||||
{
|
{
|
||||||
window->CloseActiveWindow();
|
window->CloseActiveWindow();
|
||||||
@ -50,7 +50,7 @@ public:
|
|||||||
Graphics * g = GetGraphics();
|
Graphics * g = GetGraphics();
|
||||||
g->clearrect(Position.X, Position.Y, Size.X, Size.Y);
|
g->clearrect(Position.X, Position.Y, Size.X, Size.Y);
|
||||||
}
|
}
|
||||||
void setOption(std::string option)
|
void setOption(String option)
|
||||||
{
|
{
|
||||||
dropDown->SetOption(option);
|
dropDown->SetOption(option);
|
||||||
if (dropDown->callback)
|
if (dropDown->callback)
|
||||||
@ -129,16 +129,16 @@ void DropDown::OnMouseLeave(int x, int y)
|
|||||||
{
|
{
|
||||||
isMouseInside = false;
|
isMouseInside = false;
|
||||||
}
|
}
|
||||||
std::pair<std::string, int> DropDown::GetOption()
|
std::pair<String, int> DropDown::GetOption()
|
||||||
{
|
{
|
||||||
if(optionIndex!=-1)
|
if(optionIndex!=-1)
|
||||||
{
|
{
|
||||||
return options[optionIndex];
|
return options[optionIndex];
|
||||||
}
|
}
|
||||||
return std::pair<std::string, int>("", -1);
|
return std::pair<String, int>("", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropDown::SetOption(std::string option)
|
void DropDown::SetOption(String option)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < options.size(); i++)
|
for (size_t i = 0; i < options.size(); i++)
|
||||||
{
|
{
|
||||||
@ -162,7 +162,7 @@ void DropDown::OnMouseLeave(int x, int y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void DropDown::AddOption(std::pair<std::string, int> option)
|
void DropDown::AddOption(std::pair<String, int> option)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < options.size(); i++)
|
for (size_t i = 0; i < options.size(); i++)
|
||||||
{
|
{
|
||||||
@ -171,7 +171,7 @@ void DropDown::OnMouseLeave(int x, int y)
|
|||||||
}
|
}
|
||||||
options.push_back(option);
|
options.push_back(option);
|
||||||
}
|
}
|
||||||
void DropDown::RemoveOption(std::string option)
|
void DropDown::RemoveOption(String option)
|
||||||
{
|
{
|
||||||
start:
|
start:
|
||||||
for (size_t i = 0; i < options.size(); i++)
|
for (size_t i = 0; i < options.size(); i++)
|
||||||
@ -185,7 +185,7 @@ void DropDown::OnMouseLeave(int x, int y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void DropDown::SetOptions(std::vector<std::pair<std::string, int> > options)
|
void DropDown::SetOptions(std::vector<std::pair<String, int> > options)
|
||||||
{
|
{
|
||||||
this->options = options;
|
this->options = options;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ class DropDownWindow;
|
|||||||
class DropDownAction
|
class DropDownAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void OptionChanged(DropDown * sender, std::pair<std::string, int> newOption) {}
|
virtual void OptionChanged(DropDown * sender, std::pair<String, int> newOption) {}
|
||||||
virtual ~DropDownAction() {}
|
virtual ~DropDownAction() {}
|
||||||
};
|
};
|
||||||
class DropDown: public ui::Component {
|
class DropDown: public ui::Component {
|
||||||
@ -20,15 +20,15 @@ class DropDown: public ui::Component {
|
|||||||
bool isMouseInside;
|
bool isMouseInside;
|
||||||
int optionIndex;
|
int optionIndex;
|
||||||
DropDownAction * callback;
|
DropDownAction * callback;
|
||||||
std::vector<std::pair<std::string, int> > options;
|
std::vector<std::pair<String, int> > options;
|
||||||
public:
|
public:
|
||||||
DropDown(Point position, Point size);
|
DropDown(Point position, Point size);
|
||||||
std::pair<std::string, int> GetOption();
|
std::pair<String, int> GetOption();
|
||||||
void SetOption(int option);
|
void SetOption(int option);
|
||||||
void SetOption(std::string option);
|
void SetOption(String option);
|
||||||
void AddOption(std::pair<std::string, int> option);
|
void AddOption(std::pair<String, int> option);
|
||||||
void RemoveOption(std::string option);
|
void RemoveOption(String option);
|
||||||
void SetOptions(std::vector<std::pair<std::string, int> > options);
|
void SetOptions(std::vector<std::pair<String, int> > options);
|
||||||
void SetActionCallback(DropDownAction * action) { callback = action;}
|
void SetActionCallback(DropDownAction * action) { callback = action;}
|
||||||
virtual void Draw(const Point& screenPos);
|
virtual void Draw(const Point& screenPos);
|
||||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user