Move old Lua API into another file, make the old drawin API have the old position quirk for rects, new graphics (gfx) api with drawRect, fillRect, drawTect, drawLine and textSize functions.
This commit is contained in:
parent
261c654ca0
commit
9a42e47eb0
@ -9,6 +9,37 @@
|
||||
#include "Format.h"
|
||||
#include "graphics/Graphics.h"
|
||||
|
||||
std::string format::URLEncode(std::string source)
|
||||
{
|
||||
char * src = (char *)source.c_str();
|
||||
char * dst = new char[(source.length()*3)+2];
|
||||
std::fill(dst, dst+(source.length()*3)+2, 0);
|
||||
|
||||
char *d;
|
||||
unsigned char *s;
|
||||
|
||||
for (d=dst; *d; d++) ;
|
||||
|
||||
for (s=(unsigned char *)src; *s; s++)
|
||||
{
|
||||
if ((*s>='0' && *s<='9') ||
|
||||
(*s>='a' && *s<='z') ||
|
||||
(*s>='A' && *s<='Z'))
|
||||
*(d++) = *s;
|
||||
else
|
||||
{
|
||||
*(d++) = '%';
|
||||
*(d++) = hex[*s>>4];
|
||||
*(d++) = hex[*s&15];
|
||||
}
|
||||
}
|
||||
*d = 0;
|
||||
|
||||
std::string finalString(dst);
|
||||
delete[] dst;
|
||||
return finalString;
|
||||
}
|
||||
|
||||
std::string format::UnixtimeToDate(time_t unixtime, std::string dateFormat)
|
||||
{
|
||||
struct tm * timeData;
|
||||
|
@ -7,6 +7,8 @@ class VideoBuffer;
|
||||
|
||||
namespace format
|
||||
{
|
||||
static char hex[] = "0123456789ABCDEF";
|
||||
|
||||
template <typename T> std::string NumberToString(T number)
|
||||
{
|
||||
std::stringstream ss;
|
||||
@ -21,6 +23,7 @@ namespace format
|
||||
return (ss >> number)?number:0;
|
||||
}
|
||||
|
||||
std::string URLEncode(std::string value);
|
||||
std::string UnixtimeToDate(time_t unixtime, std::string dateFomat = "%d %b %Y");
|
||||
std::string UnixtimeToDateMini(time_t unixtime);
|
||||
std::vector<char> VideoBufferToPNG(const VideoBuffer & vidBuf);
|
||||
|
1837
src/cat/LegacyLuaAPI.cpp
Normal file
1837
src/cat/LegacyLuaAPI.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,27 +8,27 @@
|
||||
#ifndef LUASCRIPTHELPER_H_
|
||||
#define LUASCRIPTHELPER_H_
|
||||
|
||||
GameModel * luacon_model;
|
||||
Simulation * luacon_sim;
|
||||
LuaScriptInterface * luacon_ci;
|
||||
Graphics * luacon_g;
|
||||
Renderer * luacon_ren;
|
||||
extern GameModel * luacon_model;
|
||||
extern Simulation * luacon_sim;
|
||||
extern LuaScriptInterface * luacon_ci;
|
||||
extern Graphics * luacon_g;
|
||||
extern Renderer * luacon_ren;
|
||||
|
||||
bool *luacon_currentCommand;
|
||||
string *luacon_lastError;
|
||||
extern bool *luacon_currentCommand;
|
||||
extern std::string *luacon_lastError;
|
||||
|
||||
int *lua_el_func, *lua_el_mode, *lua_gr_func;
|
||||
extern int *lua_el_func, *lua_el_mode, *lua_gr_func;
|
||||
|
||||
int getPartIndex_curIdx;
|
||||
int step_functions[6];//[6] = {0, 0, 0, 0, 0, 0};
|
||||
int keypress_function_count;// = 0;
|
||||
int *keypress_functions;// = NULL;
|
||||
int mouseclick_function_count;// = 0;
|
||||
int *mouseclick_functions;// = NULL;
|
||||
int tptProperties; //Table for some TPT properties
|
||||
int tptPropertiesVersion;
|
||||
int tptElements; //Table for TPT element names
|
||||
int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPartMeta, tptPart, cIndex;
|
||||
extern int getPartIndex_curIdx;
|
||||
extern int step_functions[6];//[6] = {0, 0, 0, 0, 0, 0};
|
||||
extern int keypress_function_count;// = 0;
|
||||
extern int *keypress_functions;// = NULL;
|
||||
extern int mouseclick_function_count;// = 0;
|
||||
extern int *mouseclick_functions;// = NULL;
|
||||
extern int tptProperties; //Table for some TPT properties
|
||||
extern int tptPropertiesVersion;
|
||||
extern int tptElements; //Table for TPT element names
|
||||
extern int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPartMeta, tptPart, cIndex;
|
||||
|
||||
void luacon_hook(lua_State *L, lua_Debug *ar);
|
||||
int luacon_step(int mx, int my, int selectl, int selectr, int bsx, int bsy);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -45,7 +45,8 @@ namespace pim
|
||||
#define LUACON_EL_MODIFIED_MENUS 0x4
|
||||
|
||||
class TPTScriptInterface;
|
||||
class LuaScriptInterface: public CommandInterface {
|
||||
class LuaScriptInterface: public CommandInterface
|
||||
{
|
||||
int luacon_mousex, luacon_mousey, luacon_selectedl, luacon_selectedr, luacon_mousebutton, luacon_brushx, luacon_brushy;
|
||||
bool luacon_mousedown;
|
||||
bool currentCommand;
|
||||
@ -84,6 +85,14 @@ class LuaScriptInterface: public CommandInterface {
|
||||
//VM
|
||||
void initVirtualMachineAPI();
|
||||
static int virtualMachine_loadProgram(lua_State * l);
|
||||
|
||||
void initGraphicsAPI();
|
||||
static int graphics_textSize(lua_State * l);
|
||||
static int graphics_drawText(lua_State * l);
|
||||
static int graphics_drawLine(lua_State * l);
|
||||
static int graphics_drawRect(lua_State * l);
|
||||
static int graphics_fillRect(lua_State * l);
|
||||
|
||||
public:
|
||||
ui::Window * Window;
|
||||
lua_State *l;
|
||||
|
Reference in New Issue
Block a user