18#include <emscripten.h>
26#if defined(ARM) || defined(RASPI)
29size_t strlen(
const char *);
31size_t strlen(
const char *);
81 old_time =
ev.mainloop_api.get_time();
83 void update(
Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
86 float current_time =
ev.mainloop_api.get_time();
87 float delta = current_time - old_time;
88 if (delta > time &&
vec.size()>0)
104 TimedWidget(
GameApi::EveryApi &
ev,
GuiWidget *next,
GameApi::W (*timed_func)(
void*),
void*data,
GuiWidgetForward *insert_wid,
float start_duration,
float duration,
float dx) :
GuiWidgetForward(
ev, {next}), next(next), timed_func(timed_func),
data(
data), insert_wid(insert_wid), start_duration(start_duration), duration(duration),dx(dx)
108 Point2d p = { -666.0, -666.0 };
110 Point2d p2 = { 0.0, 0.0 };
114 void update(
Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
119 if (state==0 && mouse_pos.
x>
pos.x && mouse_pos.
x<
pos.x+sz.
dx &&
123 state1_time =
ev.mainloop_api.get_time();
125 float current_time =
ev.mainloop_api.get_time();
126 if (state==1 && current_time-state1_time > start_duration)
129 state2_time =
ev.mainloop_api.get_time();
146 insert_wid->vec.push_back(tm);
147 index = insert_wid->vec.size()-1;
149 if (state==2 && (current_time-state2_time > duration||
150 !(mouse_pos.
x>
pos.x && mouse_pos.
x<
pos.x+sz.
dx &&
151 mouse_pos.
y>
pos.y && mouse_pos.
y<
pos.y+sz.
dy))
155 int s = insert_wid->vec.size();
159 std::string
id = w->get_id();
162 insert_wid->vec.erase(insert_wid->vec.begin()+i);
168 !(mouse_pos.
x>
pos.x && mouse_pos.
x<
pos.x+sz.
dx &&
169 mouse_pos.
y>
pos.y && mouse_pos.
y<
pos.y+sz.
dy))
186 float start_duration=0.0;
189 float state1_time=0.0;
190 float state2_time=0.0;
201 DynamicTextGuiWidget(
GameApi::Env &e,
GameApi::EveryApi &ev,
GameApi::GuiApi &gui, std::string need_letters, std::string *dyn_text,
void (*fptr)(
void*,
float mouse_x,
float mouse_y,
int button,
int ch,
int type,
int mouse_wheel_y),
void *user_ptr,
GameApi::FtA atlas,
GameApi::BM atlas_bm,
int x_gap) :
GuiWidgetForward(ev,
std::vector<
GuiWidget*>()), e(e), ev(ev), gui(gui), need_letters(need_letters), dyn_text(dyn_text), fptr(fptr), user_ptr(user_ptr), atlas(atlas), atlas_bm(atlas_bm), x_gap(x_gap) {
208 GameApi::W w = gui.text(s, atlas, atlas_bm, 0);
209 letter_widgets[ch]=w;
210 letter_widgets2.push_back(w);
211 letter_chars2.push_back(ch);
218 fptr(user_ptr, mouse.
x, mouse.
y, button, ch, type, mouse_wheel_y);
219 int s = letter_widgets2.size();
224 ww->
update(mouse,button,ch,type,mouse_wheel_y);
235 if (letter_widgets.find(ch2)==letter_widgets.end())
243 std::string ss = *dyn_text;
266 int s = need_letters.size();
270 int delta =
calc_top(need_letters[i]);
271 if (delta<min_delta) min_delta=delta;
284 int s = letter_widgets2.size();
296 char ch = letter_chars2[0];
315 std::string need_letters;
316 std::string *dyn_text;
317 std::map<int, GameApi::W> letter_widgets;
318 std::vector<GameApi::W> letter_widgets2;
319 std::string letter_chars2;
322 void (*fptr)(
void*,
float mouse_x,
float mouse_y,
int button,
int ch,
int type,
int mouse_wheel_y);
335 Point2d p = { -666.0, -666.0 };
337 Point2d p2 = { 0.0, 0.0 };
349 outer->set_size(outer->get_size());
350 size = outer->get_size();
354 if (p.
x >= outer->get_pos().x && p.
x < outer->get_pos().x + outer->get_size().dx)
356 if (p.
y >= outer->get_pos().y && p.
y < outer->get_pos().y + outer->get_size().dy)
359 return inner->get_pos() +
Vector2d(inner->get_size().dx/2,inner->get_size().dy/2);
372 size =
Vector2d(outer->get_size().dx,outer->get_size().dy);
402 HideWidgetIfArrayEmpty(
GameApi::Env &env,
GameApi::EveryApi &ev,
GuiWidget *w2, std::vector<GuiWidget*> items,
GameApi::W *redraw_w) :
GuiWidgetForward(ev, { w2 }),
env(
env),
ev(
ev), w(w2), items(items), redraw_w(redraw_w)
404 Point2d p = { -666.0, -666.0 };
406 Point2d p2 = { 0.0, 0.0 };
418 w->set_size(w->get_size());
419 size = w->get_size();
425 int s = items.size();
441 int s = items.size();
444 items[i]->update(mouse,button,ch,type,mouse_wheel_y);
461 if ((redraw_w && !inside_redraw) && ( button==-1 && ch==-1 && type==-1 ) ) {
465 Point2d p = { -666.0, -666.0 };
466 ww->
update(p, -1,-1, -1,1);
473 ww->
update(mouse,button,ch,type,mouse_wheel_y);
517 std::vector<GuiWidget*> items;
518 mutable bool is_currently_visible=
false;
519 static bool inside_redraw;
523bool HideWidgetIfArrayEmpty::inside_redraw=
false;
530 HideNonSearchableGuiWidget(
GameApi::Env &env,
GameApi::EveryApi &ev,
GuiWidget *w2, std::string label,
GameApi::W *redraw_w) :
GuiWidgetForward(ev, { w2 }),
env(
env),
ev(
ev), w(w2), label(label), redraw_w(redraw_w) {
531 Point2d p = { -666.0, -666.0 };
533 Point2d p2 = { 0.0, 0.0 };
546 w->set_size(w->get_size());
547 size = w->get_size();
561 if (
is_visible2()|| (ch==-1&&button==-1&&type==-1))
562 w->update(mouse,button,ch,type,mouse_wheel_y);
565 size = w->get_size();
613 if (searchstring.size()>0 && searchstring[0]==
'@') searchstring=searchstring.substr(1,searchstring.size()-1);
614 int s = label.size();
615 int s2 = searchstring.size();
616 for(
int i=0;i<s-s2+1;i++)
619 for(
int j=0;j<s2;j++)
621 if (label[i+j]!=searchstring[j]) found=
false;
623 if (found)
return true;
646 mutable bool is_currently_visible =
false;
648 static bool inside_redraw;
651bool HideNonSearchableGuiWidget::inside_redraw =
false;
661 for(
int i=0;i<s;i++) {
662 vec[i]->update(mouse,button,ch,type,mouse_wheel_y);
669 for(
int i=0;i<s;i++) {
676 if (cho>=0&&cho<vec.size())
683 std::vector<GuiWidget*> vec;
695 for(
int i=0;i<s;i++) {
696 vec[i]->update(mouse,button,ch,type,mouse_wheel_y);
710 for(
int i=0;i<s;i++) {
716 std::vector<GuiWidget*> vec;
728 TextGuiWidgetAtlas(
GameApi::EveryApi &
ev, std::string label,
GameApi::FtA atlas,
GameApi::BM atlas_bm,
GameApi::SH sh,
int x_gap) :
GuiWidgetForward(
ev,
std::vector<
GuiWidget*>()), label(label), atlas(atlas), atlas_bm(atlas_bm), sh(sh), x_gap(x_gap) { firsttime =
true;
730 Point2d p = { -666.0, -666.0 };
734 sh =
ev.shader_api.texture_shader(
true);
740 std::string display_label = label;
742 display_label =
g_conv_table->convert_labels_to_chars(display_label);
746 rendered_bitmap =
ev.font_api.font_string_from_atlas(
ev, atlas, atlas_bm, display_label.c_str(), x_gap*1.2);
753 int sx =
ev.bitmap_api.size_x(rendered_bitmap);
754 int sy =
ev.bitmap_api.size_y(rendered_bitmap);
756 scaled_bitmap = rendered_bitmap;
757 std::stringstream ss;
758 ss << sx <<
" " << sy;
759 std::string key = label + ss.str();
760 std::map<std::string,int>::iterator i =
shared_text.find(key);
764 rendered_bitmap_va.id = (*i).second;
766 rendered_bitmap_va =
ev.sprite_api.create_vertex_array(scaled_bitmap,
false,
true);
772 size.dx =
ev.bitmap_api.size_x(scaled_bitmap);
773 size.dy =
ev.bitmap_api.size_y(scaled_bitmap);
785 ev.shader_api.use(sh);
786 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x,p.
y,0.0));
787 ev.sprite_api.render_sprite_vertex_array(rendered_bitmap_va);
793 return rendered_bitmap.id;
814 Point2d p = { -666.0, -666.0 };
821 bool changed =
false;
824 if (button == 0 && type==1025 && mouse.
x>=
pos.x && mouse.
x <
pos.x+sz.
dx
837 std::stringstream ss;
844 int s = allowed_chars.size();
847 if (allowed_chars[i]==ch)
853 if (ch==8 && label.size()>0)
855 label.erase(label.begin()+(label.size()-1));
863 std::stringstream ss2(label);
868 if (firsttime || changed)
870 rendered_bitmap =
ev.font_api.font_string(font, label.c_str(), 2);
871 rendered_bitmap_va =
ev.sprite_api.create_vertex_array(rendered_bitmap);
874 size.dx =
ev.bitmap_api.size_x(rendered_bitmap);
875 size.dy =
ev.bitmap_api.size_y(rendered_bitmap);
883 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x+0.5,p.
y+0.5,0.0));
884 ev.sprite_api.render_sprite_vertex_array(rendered_bitmap_va);
889 return rendered_bitmap.id;
893 std::string allowed_chars;
896 std::string oldlabel;
911 static void set(
T &target, std::string s,
bool allow_expr, std::string &expr) { std::stringstream ss(s); ss >> target; expr=s; }
912 static void get(
const T &target, std::string &s,
bool allow_expr, std::string &expr) { std::stringstream ss; ss << target; s=ss.str(); }
913 static std::string
error(
const std::string &target,
const std::string &dd) {
return "Drag & Drop not allowed for the type!"; }
919 static void set(std::string &target, std::string s,
bool allow_expr, std::string &expr) {
if (allow_expr) { expr=s; s=
StringExprEval(expr); }
else { s=
StringExprEval(s); } target = s; }
920 static void get(
const std::string &target, std::string &s,
bool allow_expr, std::string &expr) {
if (allow_expr && expr!=
"" && expr!=
"@") s= expr;
else s= target; }
921 static std::string
error(
const std::string &target,
const std::string &dd_ext) {
922 std::string filename = target;
923 std::string ext = filename.size()<4?
"@":filename.substr(filename.size()-3);
925 return std::string(
"Drag & Drop not allowed for the extension .") + ext +
", since required: ." + dd_ext +
"!"; }
931 static void set(
float &target, std::string s,
bool allow_expr, std::string &expr) {
if (allow_expr) { expr = s; s=
FloatExprEval(expr); }
else s =
FloatExprEval(s); std::stringstream ss(s); ss >> target; }
932 static void get(
const float &target, std::string &s,
bool allow_expr, std::string &expr) { std::stringstream ss;
if (allow_expr && expr!=
"" && expr!=
"@") ss << expr;
else ss << target; s=ss.str(); }
933 static std::string
error(
const std::string &target,
const std::string &dd) {
return "Drag & Drop not allowed for the type float!"; }
940 static void set(
int &target, std::string s,
bool allow_expr, std::string &expr) {
if (allow_expr) { expr = s; s=
IntExprEval(expr); }
else s =
IntExprEval(s); std::stringstream ss(s); ss >> target; }
941 static void get(
const int &target, std::string &s,
bool allow_expr, std::string &expr) { std::stringstream ss;
if (allow_expr && expr!=
"" && expr!=
"@") ss << expr;
else ss << target; s=ss.str(); }
942 static std::string
error(
const std::string &target,
const std::string &dd) {
return "Drag & Drop not allowed for the type int!"; }
949 MultilineEditor(
GameApi::EveryApi &
ev, std::string allowed_chars,
T &target_m,
GameApi::FI font,
GameApi::SH sh,
int x_gap,
int line_height) :
GuiWidgetForward(
ev,
std::vector<
GuiWidget*>()), allowed_chars(allowed_chars), target(target_m), font(font), sh(sh), x_gap(x_gap), line_height(line_height) {
950 firsttime =
true; active=
false;
951 Point2d p = { -666.0, -666.0 };
959 bool changed =
false;
962 if (button == 0 && type==1025 && mouse.
x>=
pos.x && mouse.
x <
pos.x+sz.
dx
967 else if (button==0 && type==1025)
972 if (type==768 && (ch==1073742049||ch==1073742053)) { shift=
true; std::cout <<
"Shift1" << std::endl; }
973 if (type==769 && (ch==1073742049||ch==1073742053)) { shift=
false; std::cout <<
"Shift2" << std::endl; }
981 if (ch>=4 && ch<=29) { ch = ch - 4; ch=ch+
'a'; }
983 if (ch>=30 && ch<=38) { ch = ch-30; ch=ch+
'1'; }
985 if (ch==13) { ch=
'\n'; }
988 const char *chars1 =
"";
989 const char *chars2 =
"";
991 const char *chars1 =
"§1234567890+',.-abcdefghijklmnopqrstuvwxyz";
992 const char *chars2 =
"œ!\"#€%&/()=?*;:_ABCDEFGHIJKLMNOPQRSTUVWXYZ";
994 int s = strlen(chars1);
997 if (ch == chars1[i]) ch=chars2[i];
1001 if (active && type==768)
1003 int s = allowed_chars.size();
1004 for(
int i=0;i<s;i++)
1006 if (allowed_chars[i]==ch)
1008 label.push_back(ch);
1012 if ((ch==8 ||ch==42) && label.size()>0)
1014 label.erase(label.begin()+(label.size()-1));
1025 if (firsttime || changed)
1027 rendered_bitmap =
ev.font_api.draw_text_string(font, label, x_gap, line_height);
1031 scaled_bitmap = rendered_bitmap;
1032 rendered_bitmap_va =
ev.sprite_api.create_vertex_array(scaled_bitmap);
1035 size.dx =
ev.bitmap_api.size_x(scaled_bitmap);
1036 size.dy =
ev.bitmap_api.size_y(scaled_bitmap);
1045 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x+0.5,p.
y+0.5,0.0));
1046 ev.sprite_api.render_sprite_vertex_array(rendered_bitmap_va);
1052 std::string allowed_chars;
1075int find_str(std::string val, std::string repl);
1081 int s =
chars.size();
1082 for(
int i=0;i<s;i++)
if (ch==
chars[i])
return true;
1097 EditorGuiWidgetAtlas(
GameApi::Env &env,
GameApi::EveryApi &
ev, std::string allowed_chars,
T &target_m,
GameApi::FtA atlas,
GameApi::BM atlas_bm,
GameApi::SH sh,
int x_gap,
bool allow_expr=
false, std::string &expr =
g_temp44,
int non_editable=0,
GameApi::W *redraw_w=0) : env(env),
GuiWidgetForward(
ev,
std::vector<
GuiWidget*>()), allowed_chars(allowed_chars), target(target_m), atlas(atlas), atlas_bm(atlas_bm), sh(sh), x_gap(x_gap), allow_expr(allow_expr), expr(expr),non_editable(non_editable),redraw_w(redraw_w) {
firsttime =
true; active=
false;
1098 Point2d p = { -666.0, -666.0 };
1105 sh =
ev.shader_api.texture_shader(
true);
1110 if (inside_redraw)
return;
1111 bool changed =
false;
1118 if (button == 0 && type==1025 && mouse.
x>=
pos.x && mouse.
x <
pos.x+sz.
dx
1124 else if (button==0 && type==1025)
1132 if (button==0 && type==1024) state=1;
1133 if (button!=0 && type==1024) state=0;
1142 std::string ext = filename.size()<4?
"@":filename.substr(filename.size()-3);
1143 if (drag_drop_ext == ext
1144 ||((ext==
".ds"||ext==
"obj")&&(drag_drop_ext==
".ds"||drag_drop_ext==
"obj"))
1145 ||((ext==
"jpg"||ext==
"png"||ext==
"peg")&&(drag_drop_ext==
"jpg"||drag_drop_ext==
"png"||drag_drop_ext==
"peg"))
1148 label=
"@" + filename;
1153 std::cout << err << std::endl;
1160 bool shiftactiveevent=
false;
1161 if (type==768 && (ch==1073742049||ch==1073742053)) { shift=
true; shiftactiveevent=
true;}
1162 if (type==769 && (ch==1073742049||ch==1073742053)) { shift=
false; }
1163 if (type==768 && (ch==1073742048||ch==1073742052)) { ctrl =
true; }
1164 if (type==769 && (ch==1073742048||ch==1073742052)) { ctrl =
false; }
1165 if (type==768 && (ch==1073742054)) { altgr=
true; }
1166 if (type==769 && (ch==1073742054)) { altgr=
false; }
1173 if (
find_str(label,
"$(tempdir)") != -1) {
1178 if ((l1=
find_str(label,
"$(instdir)")) != -1 ||
1179 (l2=
find_str(label,
"$(INSTDIR)")) != -1)
1182 if (l1!=-1) chosen=
"$(instdir)";
1183 if (l2!=-1) chosen=
"$(INSTDIR)";
1185 std::cout <<
"Note: " << chosen <<
" is the same as " << cd2 << std::endl;
1193 int l1=-1,l2=-1,l3=-1,l4=-1;
1194 if ((l1=
find_str(label,
"%CD%")) != -1
1195 ||(l2=
find_str(label,
"%cd")) != -1
1196 ||(l3=
find_str(label,
"$(pwd)")) != -1
1197 ||(l4=
find_str(label,
"$(PWD)")) != -1)
1199 std::string chosen=
"";
1200 if (l1!=-1) chosen=
"%CD%";
1201 if (l2!=-1) chosen=
"%cd%";
1202 if (l3!=-1) chosen=
"$(pwd)";
1203 if (l4!=-1) chosen=
"$(PWD)";
1207 char buffer3[MAX_PATH];
1208 if (_getcwd(buffer3,
sizeof(buffer3))) {
1209 std::string cd = buffer3;
1212 char buffer3[PATH_MAX];
1214 getcwd(buffer3, PATH_MAX);
1217 std::string cd = buffer3;
1221 std::cout <<
"Note: " << chosen <<
" is the same as " << cd << std::endl;
1228 std::string ext = label.size()<4?
"$":label.substr(label.size()-3);
1229 drag_drop_ext = ext;
1238 if (ch>=4 && ch<=29) { ch = ch - 4; ch=ch+
'a'; }
1240 if (ch>=30 && ch<=38) { ch = ch-30; ch=ch+
'1'; }
1243 if (ch==229) { ch=
'\xE5'; }
1244 if (ch==246) { ch=
'\xF6'; }
1245 if (ch==228) { ch=
'\xE4'; }
1247 if (ch==13) { ch=
'\n'; }
1248 if (altgr && ch==
'4') { ch=
'$'; }
1249 if (ctrl && ch==
's') { ch=0; }
1250 if (active && ctrl && type==768 && ch==118)
1252 char *buf =
g_low->sdl->SDL_GetClipboardText();
1253 std::string buf2 = buf;
1254 int s = buf2.size();
1256 for(
int i=0;i<s;i++) {
1257 int s2 = allowed_chars.size();
1258 bool insert =
false;
1259 for(
int j=0;j<s2;j++) {
1260 if (allowed_chars[j]==buf2[i]) { insert=
true;
break; }
1262 if (insert) buf3.push_back(buf2[i]);
1268 if (active && ctrl && type==768 && ch==99) {
1269 g_low->sdl->SDL_SetClipboardText(label.c_str());
1272 if (active && ctrl) ch=0;
1276 const unsigned char *chars1 = (
unsigned char*)
"";
1277 const unsigned char *chars2 = (
unsigned char*)
"";
1279 const unsigned char *chars1 = (
unsigned char*)
"abcdefghijklmnopqrstuvwxyz\xE5\xE4\xF6 13567890+',.-";
1280 const unsigned char *chars2 = (
unsigned char*)
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\xC5\xC4\xD6 !#%&/()=?*;:_";
1282 int s = strlen((
const char*)chars1);
1283 for(
int i=0;i<s;i++)
1285 if ((((
unsigned int)ch)&0xff) == (((
unsigned int)(chars1[i]))&0xff)) { ch=(int)(((
unsigned int)(chars2[i]))&0xff);
1296 const unsigned char *chars1 = (
unsigned char*)
"";
1297 const unsigned char *chars2 = (
unsigned char*)
"";
1299 const unsigned char *chars1 = (
unsigned char*)
"024789+'3";
1300 const unsigned char *chars2 = (
unsigned char*)
"}@${[]\\¸£";
1302 int s = strlen((
const char*)chars1);
1303 for(
int i=0;i<s;i++)
1305 if (ch == chars1[i]) {
1306 ch=(
unsigned char)(chars2[i]);
1319 if (active && type==768 && !changed && !shiftactiveevent)
1321 int s = allowed_chars.size();
1322 for(
int i=0;i<s;i++)
1324 if ((
int((
unsigned int)allowed_chars[i])&0xff)==(ch&0xff))
1326 label.push_back(ch);
1332 if ((ch==8 ||ch==42) && label.size()>non_editable)
1334 if (label.size()>4 && label.size()>non_editable+4) {
1336 if (loc!=-1 && loc==label.size()-5)
1338 label.erase(label.begin()+(label.size()-1));
1339 label.erase(label.begin()+(label.size()-1));
1340 label.erase(label.begin()+(label.size()-1));
1341 label.erase(label.begin()+(label.size()-1));
1342 label.erase(label.begin()+(label.size()-1));
1346 label.erase(label.begin()+(label.size()-1));
1351 label.erase(label.begin()+(label.size()-1));
1367 if (firsttime || changed||externally_set)
1369 externally_set=
false;
1370 std::string display_label = label;
1374 rendered_bitmap =
ev.font_api.font_string_from_atlas(
ev, atlas, atlas_bm, non_editable>0?(std::string(
"[ ") + std::string(display_label.substr(1,display_label.size()-1))+std::string(
" ]")).c_str():display_label.c_str(), x_gap*1.2);
1378 scaled_bitmap = rendered_bitmap;
1379 rendered_bitmap_va =
ev.sprite_api.create_vertex_array(scaled_bitmap,
false,
true);
1382 if (redraw_w && !inside_redraw) {
1383 inside_redraw=
true;
1386 Point2d p = { -666.0, -666.0 };
1387 ww->
update(p, -1,-1, -1,1);
1393 ww->
update(mouse,button,ch,type,mouse_wheel_y);
1406 inside_redraw=
false;
1409 size.dx =
ev.bitmap_api.size_x(scaled_bitmap);
1410 size.dy =
ev.bitmap_api.size_y(scaled_bitmap);
1414 if (inside_redraw)
return;
1419 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x+0.5,p.
y+0.5,0.0));
1421 ev.sprite_api.render_sprite_vertex_array(rendered_bitmap_va);
1424 if (redraw_w && !inside_redraw) {
1425 inside_redraw=
true;
1428 inside_redraw=
false;
1436 return rendered_bitmap.id;
1439 if (non_editable!=0) {
1440 label =
"@" + value;
1447 externally_set=
true;
1452 std::string allowed_chars;
1458 GameApi::BM atlas_bm;
1460 GameApi::BM rendered_bitmap;
1461 GameApi::BM scaled_bitmap;
1462 GameApi::VA rendered_bitmap_va;
1468 bool externally_set=
false;
1469 std::string drag_drop_ext;
1471 GameApi::W *redraw_w=0;
1472 bool inside_redraw=
false;
1478class PolyGuiWidget :
public GuiWidgetForward
1481 PolyGuiWidget(GameApi::EveryApi &
ev, GameApi::P p, GameApi::SH sh, GameApi::SH old_sh,
int sx,
int sy,
int screen_x,
int screen_y) : GuiWidgetForward(
ev, { }), sh(sh), old_sh(old_sh), p(p), obj(
ev, p, sh),sx(sx),sy(sy), screen_x(screen_x), screen_y(screen_y) { firsttime =
true;
1482 Point2d p3 = {-666.0, -666.0 };
1484 Point2d p2 = { 0.0,0.0 };
1487 left=
false; right=
false;
1489 ~PolyGuiWidget() { }
1490 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
1493 if (ch>=4 && ch<=29) { ch = ch - 4; ch=ch+
'a'; }
1495 if (ch>=30 && ch<=38) { ch = ch-30; ch=ch+
'1'; }
1498 if (ch==
'a' && type==0x300)
1502 if (ch==
'a' && type==0x301)
1506 if (ch==
'd' && type==0x300)
1510 if (ch==
'd' && type==0x301)
1531 obj.set_rotation_y(rot_y);
1536 obj.set_rotation_y(rot_y);
1540 Point2d pos = get_pos();
1541 Vector2d sz = get_size();
1542 float scale_x = 1.0;
1543 float scale_y = 1.0;
1548 ogl->
glViewport(pos.
x*scale_x, screen_y*scale_y-pos.
y*scale_y-sz.
dy*scale_y, sz.
dx*scale_x, sz.
dy*scale_y);
1549 ev.shader_api.use(sh);
1550 ev.mainloop_api.switch_to_3d(
true, sh, screen_x, screen_y);
1555 ev.mainloop_api.clear_3d(0xff000000);
1564 ev.mainloop_api.switch_to_3d(
false, sh, screen_x, screen_y);
1566 ev.shader_api.use(old_sh);
1574 GameApi::PolygonObj obj;
1577 int screen_x, screen_y;
1582class VAGuiWidget :
public GuiWidgetForward
1585 VAGuiWidget(GameApi::EveryApi &
ev, GameApi::VA p, GameApi::SH sh, GameApi::SH old_sh,
int sx,
int sy,
int screen_x,
int screen_y) : GuiWidgetForward(
ev, { }), sh(sh), old_sh(old_sh), p(p),sx(sx),sy(sy), screen_x(screen_x), screen_y(screen_y) { firsttime =
true;
1586 Point2d p3 = {-666.0, -666.0 };
1588 Point2d p2 = { 0.0,0.0 };
1591 mat =
ev.matrix_api.identity();
1592 left=
false; right=
false;
1594 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
1597 if (ch>=4 && ch<=29) { ch = ch - 4; ch=ch+
'a'; }
1599 if (ch>=30 && ch<=38) { ch = ch-30; ch=ch+
'1'; }
1602 if (ch==
'a' && type==0x300)
1606 if (ch==
'a' && type==0x301)
1610 if (ch==
'd' && type==0x300)
1614 if (ch==
'd' && type==0x301)
1636 mat =
ev.matrix_api.yrot(rot_y);
1642 mat =
ev.matrix_api.yrot(rot_y);
1646 Point2d pos = get_pos();
1647 Vector2d sz = get_size();
1648 float scale_x = 1.0;
1649 float scale_y = 1.0;
1654 ogl->
glViewport(pos.
x*scale_x, screen_y*scale_y-pos.
y*scale_y-sz.
dy*scale_y, sz.
dx*scale_x, sz.
dy*scale_y);
1655 ev.shader_api.use(sh);
1656 ev.mainloop_api.switch_to_3d(
true, sh, screen_x, screen_y);
1661 ev.mainloop_api.clear_3d(0xff000000);
1668 ev.shader_api.set_var(sh,
"in_MV", mat);
1669 ev.polygon_api.render_vertex_array(p);
1671 ev.mainloop_api.switch_to_3d(
false, sh, screen_x, screen_y);
1672 ogl->
glViewport(0,0,screen_x*scale_x, screen_y*scale_y);
1673 ev.shader_api.use(old_sh);
1685 int screen_x, screen_y;
1692bool g_inside_ml_widget;
1707 int sz =
vec.size();
1708 if (i>=0 && i<sz &&
vec[i])
1709 vec[i]->HeavyPrepare();
1712 int sz =
vec2.size();
1713 if (i>=0 && i<sz &&
vec2[i])
1714 vec2[i]->FirstFrame();
1719 int sz =
vec.size();
1720 if (i>=0 && i<sz &&
vec[i])
1721 return vec[i]->NumBlocks();
1725 std::vector<CollectInterface*> vec;
1726 std::vector<CollectInterface*> vec2;
1735class MLGuiWidget :
public GuiWidgetForward
1738 MLGuiWidget(GameApi::Env &
env, GameApi::EveryApi &
ev, GameApi::ML p, GameApi::SH sh, GameApi::SH sh2,GameApi::SH sh_2d, GameApi::SH sh_arr, GameApi::SH old_sh,
int sx,
int sy,
int screen_x,
int screen_y) : GuiWidgetForward(
ev, { }),
env(
env), sh(sh), sh2(sh2), sh_2d(sh_2d), sh_arr(sh_arr), old_sh(old_sh), p(p),sx(sx),sy(sy), screen_x(screen_x), screen_y(screen_y) { firsttime =
true;
1739 Point2d p3 = {-666.0, -666.0 };
1741 Point2d p2 = { 0.0,0.0 };
1744 mat =
ev.matrix_api.identity();
1745 e.cursor_pos =
ev.point_api.point(0.0,0.0,0.0);
1749 left=
false; right=
false;
1756 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
1760 ev.mainloop_api.reset_time();
1769 e.cursor_pos =
ev.point_api.point(mouse.
x,mouse.
y,0.0);
1778 e.joy0_button0 = but1==1;
1779 e.joy0_button1 = but2==1;
1780 e.joy0_button2 = but3==1;
1781 e.joy0_button3 = but4==1;
1784 e.joy1_button0 =
false;
1785 e.joy1_button1 =
false;
1786 e.joy1_button2 =
false;
1787 e.joy1_button3 =
false;
1789 e.joy0_current_axis = -1;
1795 e.joy1_current_axis = -1;
1812 ev.mainloop_api.event_ml(p,
e);
1817 if (ch>=4 && ch<=29) { ch = ch - 4; ch=ch+
'a'; }
1819 if (ch>=30 && ch<=38) { ch = ch-30; ch=ch+
'1'; }
1821 if (ch==
'p' && type==0x300)
1823 keys_enabled =
false;
1825 if (ch==
'o' && type==0x300)
1827 keys_enabled =
true;
1832 if (ch==
'a' && type==0x300)
1836 if (ch==
'a' && type==0x301)
1840 if (ch==
'd' && type==0x300)
1844 if (ch==
'd' && type==0x301)
1867 if (
ev.polygon_api.ready_to_prepare(p)) {
1894 mat =
ev.matrix_api.yrot(rot_y);
1900 mat =
ev.matrix_api.yrot(rot_y);
1904 Point2d pos = get_pos();
1905 Vector2d sz = get_size();
1906 float scale_x = 1.0;
1907 float scale_y = 1.0;
1912 ogl->
glViewport(pos.
x*scale_x, screen_y*scale_y-pos.
y*scale_y-sz.
dy*scale_y, sz.
dx*scale_x, sz.
dy*scale_y);
1913 int c_x =
ev.mainloop_api.get_corner_x();
1914 int c_y =
ev.mainloop_api.get_corner_y();
1915 int c_sx =
ev.mainloop_api.get_screen_rect_sx();
1916 int c_sy =
ev.mainloop_api.get_screen_rect_sy();
1917 ev.mainloop_api.set_corner(pos.
x, pos.
y, sz.
dx,sz.
dy);
1918 ev.shader_api.use(sh);
1919 ev.mainloop_api.switch_to_3d(
true, sh, screen_x, screen_y);
1920 ev.shader_api.use(sh2);
1921 ev.mainloop_api.switch_to_3d(
true, sh2, screen_x, screen_y);
1922 ev.shader_api.use(sh_2d);
1923 ev.mainloop_api.switch_to_3d(
false, sh_2d, screen_x, screen_y);
1924 ev.shader_api.use(sh_arr);
1925 ev.mainloop_api.switch_to_3d(
true, sh_arr, screen_x, screen_y);
1928 ev.shader_api.use(sh);
1929 ev.shader_api.set_var(sh,
"in_MV", mat);
1930 ev.shader_api.use(sh2);
1931 ev.shader_api.set_var(sh2,
"in_MV", mat);
1932 ev.shader_api.use(sh_2d);
1933 ev.shader_api.set_var(sh_2d,
"in_MV", mat);
1934 ev.shader_api.use(sh_arr);
1935 ev.shader_api.set_var(sh_arr,
"in_MV", mat);
1936 ev.shader_api.use(sh);
1937 GameApi::M in_T =
ev.mainloop_api.in_T(
ev,
true);
1938 GameApi::M in_N =
ev.mainloop_api.in_N(
ev,
true);
1943 ev.mainloop_api.clear_3d(0xff000000);
1949 ev.mainloop_api.execute_ml(
ev,p, sh, sh2, sh2, sh_arr,mat, in_T, in_N, sz.
dx, sz.
dy);
1958 ev.shader_api.use(sh);
1959 ev.mainloop_api.switch_to_3d(
false, sh, screen_x, screen_y);
1960 ev.shader_api.use(sh2);
1961 ev.mainloop_api.switch_to_3d(
false, sh2, screen_x, screen_y);
1962 ev.shader_api.use(sh_arr);
1963 ev.mainloop_api.switch_to_3d(
false, sh_arr, screen_x, screen_y);
1964 ev.shader_api.use(sh_2d);
1965 ev.mainloop_api.switch_to_3d(
false, sh_2d, screen_x, screen_y);
1966 ev.mainloop_api.set_corner(c_x,c_y,c_sx,c_sy);
1967 ogl->
glViewport(0,0,screen_x*scale_x, screen_y*scale_y);
1968 ev.shader_api.use(old_sh);
1983 GameApi::MainLoopApi::Event
e;
1988 int screen_x, screen_y;
1996class ShaderPlaneGuiWidget :
public GuiWidgetForward
1999 ShaderPlaneGuiWidget(GameApi::EveryApi &
ev, GameApi::SFO p, GameApi::SH sh,
int sx,
int sy,
int screen_x,
int screen_y) : GuiWidgetForward(
ev, { }), sh(sh), p(p),sx(sx),sy(sy),screen_x(screen_x), screen_y(screen_y) { firsttime =
true;
2000 Point2d p3 = {-666.0, -666.0 };
2002 Point2d p2 = { 0.0,0.0 };
2005 time =
ev.mainloop_api.get_time();
2006 left=
false; right=
false;
2009 GameApi::V
func(
int face,
int point, GameApi::EveryApi &
ev)
2013 case 0:
return ev.vector_api.vector(0.0,0.0,0.0);
2014 case 1:
return ev.vector_api.vector(1.0,0.0,0.0);
2015 case 2:
return ev.vector_api.vector(1.0,1.0,0.0);
2016 case 3:
return ev.vector_api.vector(0.0,1.0,0.0);
2018 return ev.vector_api.vector(0.0,0.0,0.0);
2021 GameApi::PT
func2(
int face,
int point, GameApi::EveryApi &
ev)
2025 case 0:
return ev.point_api.point(0.0,1.0,0.0);
2026 case 1:
return ev.point_api.point(1.0,1.0,0.0);
2027 case 2:
return ev.point_api.point(1.0,0.0,0.0);
2028 case 3:
return ev.point_api.point(0.0,0.0,0.0);
2030 return ev.point_api.point(0.0,0.0,0.0);
2034 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2038 if (ch>=4 && ch<=29) { ch = ch - 4; ch=ch+
'a'; }
2040 if (ch>=30 && ch<=38) { ch = ch-30; ch=ch+
'1'; }
2043 if (ch==
'a' && type==0x300)
2047 if (ch==
'a' && type==0x301)
2051 if (ch==
'd' && type==0x300)
2055 if (ch==
'd' && type==0x301)
2061 using std::placeholders::_1;
2062 using std::placeholders::_2;
2066 sh2 =
ev.shader_api.get_normal_shader(
"screen",
"screen",
"",
"",
"",
false,
render);
2067 ev.mainloop_api.init(sh2, screen_x, screen_y);
2068 ev.mainloop_api.alpha(
true);
2069 GameApi::P poly_0 =
ev.polygon_api.quad_z(0.0, sx,
2072 GameApi::P poly_1 =
ev.polygon_api.normal_function(poly_0, std::bind(&ShaderPlaneGuiWidget::func,
this, _1, _2, std::ref(
ev)));
2073 GameApi::P poly_2 =
ev.polygon_api.texcoord_function(poly_1, std::bind(&ShaderPlaneGuiWidget::func2,
this, _1, _2, std::ref(
ev)));
2074 obj =
new GameApi::PolygonObj(
ev, poly_2, sh2);
2096 float f = (
ev.mainloop_api.get_time()-time)/1000.0;
2097 ev.shader_api.use(sh2);
2098 ev.shader_api.set_var(sh2,
"roty", rot_y);
2099 ev.shader_api.set_var(sh2,
"time",
f);
2100 Point2d pos = get_pos();
2102 obj->set_pos(pos.
x, pos.
y, 0.0);
2104 ev.shader_api.use(sh);
2112 GameApi::PolygonObj *obj;
2115 int screen_x, screen_y;
2121class OneItemFaceCollection :
public FaceCollection
2124 virtual std::string
name()
const {
return "OneItemFaceCollection"; }
2125 virtual void Prepare() { }
2126 virtual void HeavyPrepare() { }
2127 virtual void Collect(CollectVisitor &vis) { }
2128 virtual int NumFaces()
const {
return 1; }
2129 virtual int NumPoints(
int face)
const {
return 1; }
2130 virtual Point FacePoint(
int face,
int point)
const {
return Point(0.0,0.0,0.0); }
2131 virtual Vector PointNormal(
int face,
int point)
const {
return Vector(0.0,0.0,0.0); }
2132 virtual float Attrib(
int face,
int point,
int id)
const {
return 0.0; }
2133 virtual int AttribI(
int face,
int point,
int id)
const {
return 0; }
2134 virtual unsigned int Color(
int face,
int point)
const {
return 0xffffffff; }
2135 virtual Point2d TexCoord(
int face,
int point)
const { Point2d p; p.
x = 0.0; p.
y = 0.0;
return p; }
2144class PTSGuiWidget :
public GuiWidgetForward
2147 PTSGuiWidget(GameApi::Env &
e, GameApi::EveryApi &
ev, GameApi::PTS p, GameApi::SH sh, GameApi::SH old_sh,
int sx,
int sy,
int screen_x,
int screen_y) : GuiWidgetForward(
ev, { }), sh(sh), old_sh(old_sh), p(p), obj(
ev, p, sh,one(
e),1.0f),sx(sx),sy(sy), screen_x(screen_x), screen_y(screen_y) { firsttime =
true;
2148 Point2d p3 = {-666.0, -666.0 };
2150 Point2d p2 = { 0.0,0.0 };
2153 left=
false; right=
false;
2155 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2158 if (ch>=4 && ch<=29) { ch = ch - 4; ch=ch+
'a'; }
2160 if (ch>=30 && ch<=38) { ch = ch-30; ch=ch+
'1'; }
2162 if (ch==
'a' && type==0x300)
2166 if (ch==
'a' && type==0x301)
2170 if (ch==
'd' && type==0x300)
2174 if (ch==
'd' && type==0x301)
2195 obj.set_rotation_matrix(
ev.matrix_api.yrot(rot_y));
2200 obj.set_rotation_matrix(
ev.matrix_api.yrot(rot_y));
2204 Point2d pos = get_pos();
2205 Vector2d sz = get_size();
2207 float scale_x = 1.0;
2208 float scale_y = 1.0;
2214 ogl->
glViewport(pos.
x*scale_x, screen_y*scale_y-pos.
y*scale_y-sz.
dy*scale_y, sz.
dx*scale_x, sz.
dy*scale_y);
2215 ev.shader_api.use(sh);
2216 ev.mainloop_api.switch_to_3d(
true, sh, screen_x, screen_y);
2221 ev.mainloop_api.clear_3d(0xff000000);
2232 ev.mainloop_api.switch_to_3d(
false, sh, screen_x, screen_y);
2233 ogl->
glViewport(0,0,screen_x*scale_x, screen_y*scale_y);
2234 ev.shader_api.use(old_sh);
2242 GameApi::PointsObj obj;
2245 int screen_x, screen_y;
2251class LinesGuiWidget :
public GuiWidgetForward
2254 LinesGuiWidget(GameApi::EveryApi &
ev, GameApi::LI p, GameApi::SH sh, GameApi::SH old_sh,
int sx,
int sy,
int screen_x,
int screen_y) : GuiWidgetForward(
ev, { }), sh(sh), old_sh(old_sh), p(p), obj(
ev, p, sh),sx(sx),sy(sy), screen_x(screen_x), screen_y(screen_y) { firsttime =
true;
2255 Point2d p3 = {-666.0, -666.0 };
2257 Point2d p2 = { 0.0,0.0 };
2263 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2266 if (ch>=4 && ch<=29) { ch = ch - 4; ch=ch+
'a'; }
2268 if (ch>=30 && ch<=38) { ch = ch-30; ch=ch+
'1'; }
2270 if (ch==
'a' && type==0x300)
2274 if (ch==
'd' && type==0x300)
2278 if (ch==
'a' && type==0x301)
2282 if (ch==
'd' && type==0x301)
2303 obj.set_rotation_matrix(
ev.matrix_api.yrot(rot_y));
2308 obj.set_rotation_matrix(
ev.matrix_api.yrot(rot_y));
2312 Point2d pos = get_pos();
2313 Vector2d sz = get_size();
2314 float scale_x = 1.0;
2315 float scale_y = 1.0;
2321 ogl->
glViewport(pos.
x*scale_x, screen_y*scale_y-pos.
y*scale_y-sz.
dy*scale_y, sz.
dx*scale_x, sz.
dy*scale_y);
2322 ev.shader_api.use(sh);
2323 ev.mainloop_api.switch_to_3d(
true, sh, screen_x, screen_y);
2327 ev.mainloop_api.clear_3d(0xff000000);
2335 ev.mainloop_api.switch_to_3d(
false, sh, screen_x, screen_y);
2336 ogl->
glViewport(0,0,screen_x*scale_x, screen_y*scale_y);
2337 ev.shader_api.use(old_sh);
2345 GameApi::LinesObj obj;
2348 int screen_x, screen_y;
2353class BoundingBoxWidget :
public GuiWidgetForward
2356 BoundingBoxWidget(GuiWidget *next) : GuiWidgetForward(
ev, std::vector<GuiWidget*>{next}), next(next) {
2357 Point2d p = { -666.0, -666.0 };
2359 Point2d p2 = { 0.0, 0.0 };
2362 void set_size(Vector2d v) {
2366 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2368 if (mouse.
x<pos.
x)
return;
2369 if (mouse.
y<pos.
y)
return;
2370 if (mouse.
x>pos.
x+
size.dx)
return;
2371 if (mouse.
y>pos.
y+
size.dy)
return;
2372 next->
update(mouse,button,ch,type,mouse_wheel_y);
2380 return add_widget(e,
new BoundingBoxWidget(ww));
2389 Point2d p = { -666.0, -666.0 };
2393 if (
ev.bitmap_api.ready_to_prepare(bm)) {
2395 ev.bitmap_api.prepare(bm);
2399 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2405 if (
ev.bitmap_api.ready_to_prepare(bm)) {
2408 ev.bitmap_api.prepare(bm);
2412 size.dx =
ev.bitmap_api.size_x(bm);
2413 size.dy =
ev.bitmap_api.size_y(bm);
2416 if (
ev.bitmap_api.ready_to_prepare(bm)) {
2418 bm_va =
ev.sprite_api.create_vertex_array(bm);
2429 if (firsttime &&
ev.bitmap_api.ready_to_prepare(bm)) {
2441 Point2d p = get_pos();
2442 ev.shader_api.use(sh);
2443 ev.shader_api.set_var(sh,
"color_mix", 1.0f);
2444 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x+0.5,p.
y+0.5,0.0));
2446 ev.sprite_api.render_sprite_vertex_array(bm_va);
2474std::vector<A> shared_sprites;
2475int find_shared_sprites(
int key) {
2476 int s = shared_sprites.size();
2477 for(
int i=0;i<s;i++) {
if (shared_sprites[i].key==key)
return i; }
2481class IconGuiWidgetShared :
public GuiWidgetForward
2484 IconGuiWidgetShared(GameApi::Env &
env, GameApi::EveryApi &
ev, GameApi::BM bm, GameApi::SH sh,
int key) : GuiWidgetForward(
ev, std::vector<GuiWidget*>()),
env(
env),
ev(
ev), sh(sh), bm(bm), key(key) { firsttime=
true;
2485 Point2d p = { -666.0, -666.0 };
2487 Point2d p2 = { 0.0, 0.0 };
2491 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2494 size.dx =
ev.bitmap_api.size_x(bm);
2495 size.dy =
ev.bitmap_api.size_y(bm);
2502 int index = find_shared_sprites(key);
2504 bm_va.id = shared_sprites[index].value;
2507 GameApi::BM scaled =
ev.bitmap_api.scale_bitmap(
ev,bm, 100,100);
2508 bm_va =
ev.sprite_api.create_vertex_array(scaled);
2512 shared_sprites.push_back(a);
2517 GameApi::BM scaled =
ev.bitmap_api.scale_bitmap(
ev,bm, 100,100);
2518 bm_va =
ev.sprite_api.create_vertex_array(scaled);
2522 shared_sprites.push_back(a);
2540 Point2d p = get_pos();
2541 GameApi::M m =
ev.matrix_api.trans(p.
x+0.5,p.
y+0.5,0.0);
2542 GameApi::M ms =
ev.matrix_api.scale(
size.dx/100.0,
size.dy/100.0, 1.0);
2543 GameApi::M mc =
ev.matrix_api.mult(ms,m);
2544 ev.shader_api.use(sh);
2545 ev.shader_api.set_var(sh,
"color_mix", 1.0f);
2546 ev.shader_api.set_var(sh,
"in_MV", mc);
2547 ev.sprite_api.render_sprite_vertex_array(bm_va);
2559 GameApi::EveryApi &
ev;
2569class IconGuiWidgetSharedNoScale :
public GuiWidgetForward
2572 IconGuiWidgetSharedNoScale(GameApi::Env &
env, GameApi::EveryApi &
ev, GameApi::BM bm, GameApi::SH sh,
int key) : GuiWidgetForward(
ev, std::vector<GuiWidget*>()),
env(
env),
ev(
ev), sh(sh), bm(bm), key(key) { firsttime=
true;
2573 Point2d p = { -666.0, -666.0 };
2575 Point2d p2 = { 0.0, 0.0 };
2579 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2593 int index = find_shared_sprites(key);
2595 bm_va.id = shared_sprites[index].value;
2598 GameApi::BM scaled =
ev.bitmap_api.scale_bitmap(
ev,bm, 400,200);
2599 bm_va =
ev.sprite_api.create_vertex_array(scaled);
2603 shared_sprites.push_back(a);
2608 GameApi::BM scaled =
ev.bitmap_api.scale_bitmap(
ev,bm, 400,200);
2609 bm_va =
ev.sprite_api.create_vertex_array(scaled);
2613 shared_sprites.push_back(a);
2631 Point2d p = get_pos();
2632 GameApi::M m =
ev.matrix_api.trans(p.
x+0.5,p.
y+0.5,0.0);
2633 GameApi::M ms =
ev.matrix_api.scale(
size.dx/100.0,
size.dy/100.0, 1.0);
2634 GameApi::M mc =
ev.matrix_api.mult(ms,m);
2635 ev.shader_api.use(sh);
2636 ev.shader_api.set_var(sh,
"color_mix", 1.0f);
2637 ev.shader_api.set_var(sh,
"in_MV", mc);
2638 ev.sprite_api.render_sprite_vertex_array(bm_va);
2639 ev.shader_api.use(sh);
2650 GameApi::EveryApi &
ev;
2664struct LayoutGuiWidget_WH { };
2665struct LayoutGuiWidget_lt { };
2666struct LayoutGuiWidget_rb { };
2668class LayoutGuiWidget :
public GuiWidgetForward
2671 LayoutGuiWidget(GameApi::EveryApi &
ev, GuiWidget *w,
int l,
int t,
int W,
int H,
int r,
int b) : GuiWidgetForward(
ev, { w }), l(l), t(t), W(W), H(H), r(r), b(b)
2681 Point2d p = { -666.0, -666.0 };
2683 Point2d p2 = { 0.0, 0.0 };
2686 LayoutGuiWidget(LayoutGuiWidget_WH type, GameApi::EveryApi &
ev, GuiWidget *w,
int l,
int t,
int W,
int H,
int r,
int b,
int (*fptr_W)(
void *),
int (*fptr_H)(
void *),
void *ctx1,
void *ctx2) : GuiWidgetForward(
ev, { w }), l(l), t(t), W(W), H(H), r(r), b(b), fptr_x(fptr_W), fptr_y(fptr_H), ctx1(ctx1), ctx2(ctx2)
2696 Point2d p = { -666.0, -666.0 };
2698 Point2d p2 = { 0.0, 0.0 };
2701 LayoutGuiWidget(LayoutGuiWidget_lt type, GameApi::EveryApi &
ev, GuiWidget *w,
int l,
int t,
int W,
int H,
int r,
int b,
int (*fptr_l)(
void *),
int (*fptr_t)(
void *),
void *ctx1,
void *ctx2) : GuiWidgetForward(
ev, { w }), l(l), t(t), W(W), H(H), r(r), b(b), fptr_x(fptr_l), fptr_y(fptr_t), ctx1(ctx1), ctx2(ctx2)
2712 Point2d p = { -666.0, -666.0 };
2714 Point2d p2 = { 0.0, 0.0 };
2717 LayoutGuiWidget(LayoutGuiWidget_rb type, GameApi::EveryApi &
ev, GuiWidget *w,
int l,
int t,
int W,
int H,
int r,
int b,
int (*fptr_r)(
void *),
int (*fptr_b)(
void *),
void *ctx1,
void *ctx2) : GuiWidgetForward(
ev, { w }), l(l), t(t), W(W), H(H), r(r), b(b), fptr_x(fptr_r), fptr_y(fptr_b), ctx1(ctx1), ctx2(ctx2)
2727 Point2d p = { -666.0, -666.0 };
2729 Point2d p2 = { 0.0, 0.0 };
2732 void do_layout(Vector2d size_p)
2746 if (is_dynamic_WH) {
2752 if (is_dynamic_lt) {
2758 if (is_dynamic_rb) {
2774 void set_size(Vector2d size_p)
2779 Vector2d delta = { float(c_l+c_r), float(c_t+c_b) };
2780 vec[0]->set_size(size_p + (- delta));
2782 Vector2d v = vec[0]->get_size();
2783 Vector2d vv = { float(c_l+c_r), float(c_t+c_b) };
2784 Vector2d vvv = v+vv;
2787 void set_pos(Point2d p)
2791 Vector2d v = { float(c_l), float(c_t) };
2792 vec[0]->set_pos(p+v);
2794 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2797 Vector2d v = vec[0]->get_size();
2798 Vector2d vv = { float(c_l+c_r), float(c_t+c_b) };
2799 Vector2d vvv = v+vv;
2803 set_size(get_size());
2805 int chosen_item()
const
2807 int val = vec[0]->chosen_item();
2813 int c_l,c_t,c_W,c_H,c_r,c_b;
2814 bool is_dynamic_WH=
false;
2815 bool is_dynamic_lt=
false;
2816 bool is_dynamic_rb=
false;
2817 int (*fptr_x)(
void *);
2818 int (*fptr_y)(
void *);
2825class MarginGuiWidget :
public GuiWidgetForward
2828 MarginGuiWidget(GameApi::EveryApi &
ev, GuiWidget *w,
int l,
int t,
int r,
int b) : GuiWidgetForward(
ev, { w }), l(l), t(t), r(r), b(b)
2830 Point2d p = { -666.0, -666.0 };
2832 Point2d p2 = { 0.0, 0.0 };
2835 void set_size(Vector2d size_p)
2838 Vector2d delta = { float(l+r), float(t+b) };
2839 vec[0]->set_size(size_p + (- delta));
2841 Vector2d v = vec[0]->get_size();
2842 Vector2d vv = { float(l+r), float(t+b) };
2843 Vector2d vvv = v+vv;
2846 void set_pos(Point2d p)
2849 Vector2d v = { float(l), float(t) };
2850 vec[0]->set_pos(p+v);
2852 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2855 Vector2d v = vec[0]->get_size();
2856 Vector2d vv = { float(l+r), float(t+b) };
2857 Vector2d vvv = v+vv;
2861 set_size(get_size());
2863 int chosen_item()
const
2865 int val = vec[0]->chosen_item();
2872class SizeGuiWidget :
public GuiWidgetForward
2875 SizeGuiWidget(GameApi::EveryApi &
ev, GuiWidget *w,
int sx,
int sy) : GuiWidgetForward(
ev, { w }), sx(sx), sy(sy)
2877 Point2d p = { -666.0, -666.0 };
2879 Point2d p2 = { 0.0, 0.0 };
2882 void set_size(Vector2d
size)
2885 Vector2d delta = { float(sx), float(sy) };
2886 vec[0]->set_size(delta);
2888 void set_pos(Point2d p)
2895 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2899 Vector2d vv = { float(sx), float(sy) };
2903 int chosen_item()
const
2905 int val = vec[0]->chosen_item();
2913class LayerGuiWidget :
public GuiWidgetForward
2916 LayerGuiWidget(GameApi::EveryApi &
ev, GuiWidget *w1, GuiWidget *w2) : GuiWidgetForward(
ev, { w1, w2 })
2918 Point2d p = { -666.0, -666.0 };
2920 Point2d p2 = { 0.0, 0.0 };
2923 void set_pos(Point2d pos)
2926 vec[0]->set_pos(pos);
2927 vec[1]->set_pos(pos);
2929 void set_size(Vector2d
size)
2932 vec[0]->set_size(
size);
2933 vec[1]->set_size(
size);
2935 void update(Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
2938 Vector2d v1 = vec[0]->get_size();
2939 Vector2d v2 = vec[1]->get_size();
2940 Vector2d mx = { std::max(v1.
dx, v2.
dx), std::max(v1.
dy,v2.
dy) };
2947 int chosen_item()
const
2949 int val = vec[0]->chosen_item();
2950 if (val != -1)
return val;
2951 return vec[1]->chosen_item();
2954class ArrayXWidget :
public GuiWidgetForward
2957 ArrayXWidget(GameApi::EveryApi &
ev, std::vector<GuiWidget*> vec,
int x_gap) : GuiWidgetForward(
ev, vec), x_gap(x_gap)
2959 Point2d pos = { -666.0, -666.0 };
2960 update(pos, -1,-1, -1,0);
2961 Point2d p2 = { 0.0, 0.0 };
2964 void set_pos(Point2d pos)
2969 for(
int i=0;i<s;i++)
2971 GuiWidget *w = vec[i];
2972 Point2d p = { pos.
x + delta, pos.
y };
2977 void set_size(Vector2d
size)
2982 for(
int i=0;i<s;i++) {
2983 vec[i]->set_size(vec[i]->get_size());
2987 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
2993 for(
int i=0;i<s; i++)
2995 sz += vec[i]->get_size().dx + x_gap;
2996 sz_max = std::max(sz_max, vec[i]->get_size().
dy);
3013class ArrayYWidget :
public GuiWidgetForward
3016 ArrayYWidget(GameApi::EveryApi &
ev, std::vector<GuiWidget*> vec,
int y_gap,
bool heavy) : GuiWidgetForward(
ev, vec), y_gap(y_gap),heavy(heavy)
3018 Point2d pos = { -666.0, -666.0 };
3019 update(pos, -1,-1, -1,0);
3020 Point2d p2 = { 0.0, 0.0 };
3024 virtual Point2d get_pos()
const {
return old_pos; }
3025 virtual Vector2d get_size()
const
3030 void set_pos(Point2d pos)
3036 int s2 = vec.size();
3039 for(
int i=0;i<s2; i++)
3041 sz += vec[i]->get_size().dy + y_gap;
3042 sz_max = std::max(sz_max, vec[i]->get_size().dx);
3048 int s3 = vec.size();
3049 for(
int i=0;i<s3;i++)
3051 vec[i]->set_size(vec[i]->get_size());
3057 for(
int i=0;i<s;i++)
3059 GuiWidget *w = vec[i];
3060 Point2d p = { pos.
x, pos.
y +delta};
3066 void set_size(Vector2d size_p)
3072 for(
int i=0;i<s; i++)
3074 sz += vec[i]->get_size().dy + y_gap;
3075 sz_max = std::max(sz_max, vec[i]->get_size().dx);
3080 int s2 = vec.size();
3081 for(
int i=0;i<s2;i++)
3083 vec[i]->set_size(vec[i]->get_size());
3097 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
3102 for(
int i=0;i<s; i++)
3104 sz += vec[i]->get_size().dy + y_gap;
3105 sz_max = std::max(sz_max, vec[i]->get_size().dx);
3111 static bool recursion_stopper =
false;
3112 if (button==-1&& ch==-1 && type==-1 && heavy && !recursion_stopper) {
3113 recursion_stopper=
true;
3114 int s2 = vec.size();
3117 for(
int i=0;i<s2;i++)
3119 GuiWidget *w = vec[i];
3122 Point2d pos2 = pos + sz*0.5;
3128 recursion_stopper=
false;
3137 for(
int j=0;j<s;j++)
3139 GuiWidget *w = vec[j];
3142 if (mouse.
x>=pos.
x && mouse.
x<pos.
x+
size.dx &&
3143 mouse.
y>=pos.
y && mouse.
y<pos.
y+
size.dy)
3157 int chosen_item()
const {
return selected_item; }
3168 Point2d old_pos = { 0.0,0.0 };
3173int highlight_bitmap = -1;
3174int highlight_border = -1;
3175class HighlightGuiWidget :
public GuiWidgetForward
3178 HighlightGuiWidget(GameApi::EveryApi &
ev, GameApi::SH sh,
int sx,
int sy) : GuiWidgetForward(
ev, std::vector<GuiWidget*>()), sh(sh), enabled(false), oldenabled(false), c_changed(false) {
3182 Point2d p = { -666.0, -666.0 };
3185 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
3187 Point2d p = get_pos();
3188 Vector2d s = get_size();
3189 if (mouse.
x >= p.
x && mouse.
x < p.
x+s.
dx && mouse.
y>=p.
y && mouse.
y< p.
y+s.
dy)
3199 if (enabled!=oldenabled)
3202 oldenabled = enabled;
3206 if (highlight_bitmap != -1)
3208 empty_bm_va.id = highlight_bitmap;
3209 bm_va.id = highlight_border;
3215 GameApi::BB bg =
ev.bool_bitmap_api.bb_empty(v.
dx, v.
dy);
3216 GameApi::BB bb_1 =
ev.bool_bitmap_api.rectangle(bg, 0.0,0.0, 2.0, (
float)v.
dy);
3217 GameApi::BB bb_2 =
ev.bool_bitmap_api.rectangle(bb_1, 0.0,0.0, (
float)v.
dx, 2.0);
3218 GameApi::BB bb_3 =
ev.bool_bitmap_api.rectangle(bb_2, v.
dx-2.0,0.0, 2.0, v.
dy);
3219 GameApi::BB bb_4 =
ev.bool_bitmap_api.rectangle(bb_3, 0.0, v.
dy-2, v.
dx, 2.0);
3220 bm =
ev.bool_bitmap_api.to_bitmap(bb_4, 255,255,255,255, 0,0,0,0);
3221 bm_va =
ev.sprite_api.create_vertex_array(bm);
3222 empty_bm =
ev.bool_bitmap_api.to_bitmap(bg, 255,255,255,255, 0,0,0,0);
3223 empty_bm_va =
ev.sprite_api.create_vertex_array(empty_bm);
3224 highlight_bitmap = empty_bm_va.id;
3225 highlight_border = bm_va.id;
3234 if (!firsttime && enabled)
3236 Vector2d v = get_size();
3237 Point2d p = get_pos();
3238 GameApi::M m =
ev.matrix_api.trans(p.
x+0.5, p.
y+0.5, 0.0);
3239 GameApi::M ms =
ev.matrix_api.scale(v.
dx/100.0, v.
dy/100.0, 1.0);
3240 GameApi::M mc =
ev.matrix_api.mult(ms,m);
3241 ev.shader_api.set_var(sh,
"in_MV", mc);
3242 ev.sprite_api.render_sprite_vertex_array(bm_va);
3253 bool content_changed()
const
3257 void clear_content_changed() { c_changed =
false; }
3260 GameApi::BM empty_bm;
3262 GameApi::VA empty_bm_va;
3264 bool firsttime=
true;
3265 bool enabled =
true;
3275 float p1 = w1->get_pos().y;
3276 float p2 = w2->get_pos().
y;
3277 if (fabs(p2-p1)<0.0001)
return w1<w2;
3283class Highlight2GuiWidget :
public GuiWidgetForward
3286 Highlight2GuiWidget(GameApi::EveryApi &
ev, GuiWidget *wid, GameApi::SH sh) : GuiWidgetForward(
ev, {wid} ), sh(sh), enabled(
false), oldenabled(
false), c_changed(
false) {
3289 Point2d p = { -666.0, -666.0 };
3292 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
3295 Point2d p = get_pos();
3296 Vector2d s = get_size();
3297 if (mouse.
x >= p.
x && mouse.
x < p.
x+s.
dx && mouse.
y>=p.
y && mouse.
y< p.
y+s.
dy)
3305 if (enabled!=oldenabled)
3308 oldenabled = enabled;
3311 size = vec[0]->get_size();
3313 if (
size.dx != oldsize.dx ||
size.dy!=oldsize.dy)
3319 if ((firsttime ||changed) && enabled)
3321 Vector2d v = get_size();
3322 GameApi::BB bg =
ev.bool_bitmap_api.bb_empty(v.
dx, v.
dy);
3323 GameApi::BB bb_1 =
ev.bool_bitmap_api.rectangle(bg, 0.0,0.0, 2.0, (
float)v.
dy);
3324 GameApi::BB bb_2 =
ev.bool_bitmap_api.rectangle(bb_1, 0.0,0.0, (
float)v.
dx, 2.0);
3325 GameApi::BB bb_3 =
ev.bool_bitmap_api.rectangle(bb_2, v.
dx-2.0,0.0, 2.0, v.
dy);
3326 GameApi::BB bb_4 =
ev.bool_bitmap_api.rectangle(bb_3, 0.0, v.
dy-2, v.
dx, 2.0);
3327 bm =
ev.bool_bitmap_api.to_bitmap(bb_4, 255,255,255,255, 0,0,0,0);
3328 bm_va =
ev.sprite_api.create_vertex_array(bm);
3329 empty_bm =
ev.bool_bitmap_api.to_bitmap(bg, 255,255,255,255, 0,0,0,0);
3330 empty_bm_va =
ev.sprite_api.create_vertex_array(empty_bm);
3340 if (!firsttime && enabled)
3342 Point2d p = get_pos();
3343 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x+0.5, p.
y+0.5, 0.0));
3344 ev.sprite_api.render_sprite_vertex_array(bm_va);
3355 bool content_changed()
const
3359 void clear_content_changed() { c_changed =
false; }
3362 GameApi::BM empty_bm;
3364 GameApi::VA empty_bm_va;
3374class LineWidget :
public GuiWidgetForward
3377 LineWidget(GameApi::EveryApi &
ev, GameApi::SH sh, GuiWidget *t1,
int delta_x,
int delta_y,
3378 GuiWidget *t2,
int delta2_x,
int delta2_y, GameApi::SH sh2)
3380 t2(t2), delta2_x(delta2_x), delta2_y(delta2_y),sh2(sh2) { firsttime =
true;
3381 Point2d p = t1->get_pos();
3384 Point2d p2 = t2->get_pos();
3387 Point2d pp = { std::min(p.
x,p2.
x), std::min(p.
y,p2.
y) };
3388 Point2d pp2 = { std::max(p.
x,p2.
x), std::max(p.
y,p2.
y) };
3389 Vector2d sz = pp2-pp;
3392 Vector2d
d = { 0.0, 0.0 };
3395 void set_pos(Point2d p2)
3400 Point2d p = { -666.0, -666.0 };
3404 GameApi::PT
line_func(
int linenum,
bool id)
3407 Point2d pos = t1->get_pos();
3411 return ev.point_api.point(pos.
x, pos.
y, 0.0);
3413 Point2d pos = t2->get_pos();
3417 return ev.point_api.point(pos.
x, pos.
y, 0.0);
3419 return ev.point_api.point(0.0,0.0,0.0);
3421 GameApi::P line_to_poly(
int i,
float sx,
float sy,
float sz,
float ex,
float ey,
float ez,
unsigned int scolor,
unsigned int ecolor)
3424 GameApi::PT p1 =
ev.point_api.point(sx-2,sy,0.0);
3425 GameApi::PT p2 =
ev.point_api.point(sx,sy+2,0.0);
3426 GameApi::PT p3 =
ev.point_api.point(ex+2,ey,0.0);
3427 GameApi::PT p4 =
ev.point_api.point(ex,ey+2,0.0);
3428 GameApi:: P poly =
ev.polygon_api.quad(p1,p2,p3,p4);
3430 return ev.polygon_api.color(poly, 0xffffffff);
3432 void update(Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
3434 using std::placeholders::_1;
3435 using std::placeholders::_2;
3436 using std::placeholders::_3;
3437 using std::placeholders::_4;
3438 using std::placeholders::_5;
3439 using std::placeholders::_6;
3440 using std::placeholders::_7;
3441 using std::placeholders::_8;
3442 using std::placeholders::_9;
3445 line =
ev.lines_api.function([
this](
int a,
bool b){
return line_func(a,b); }, 1);
3446 line =
ev.lines_api.change_color(line, 0xffffffff);
3447 line_2 =
ev.polygon_api.from_lines(line, [
this](
int a,
float b,
float c,
float d,
float e,
float f,
float g,
unsigned int h,
unsigned int i) {
return line_to_poly(a,b,c,
d,
e,
f,g,h,i); });
3448 line_3 =
ev.polygon_api.create_vertex_array(line_2,
true);
3455 if (old_t1_pos.x != t1->get_pos().x ||old_t2_pos.x != t2->get_pos().x
3456 ||old_t1_pos.y != t1->get_pos().y || old_t2_pos.y != t2->get_pos().y)
3458 line =
ev.lines_api.function([
this](
int a,
bool b){
return line_func(a,b); }, 1);
3459 line =
ev.lines_api.change_color(line, 0xffffffff);
3460 line_2 =
ev.polygon_api.from_lines(line, [
this](
int a,
float b,
float c,
float d,
float e,
float f,
float g,
unsigned int h,
unsigned int i) {
return line_to_poly(a,b,c,
d,
e,
f,g,h,i); });
3463 ev.polygon_api.update_vertex_array_no_memory(line_3, line_2);
3467 old_t1_pos = t1->get_pos();
3468 old_t2_pos = t2->get_pos();
3471 Point2d p = t1->get_pos();
3475 Point2d p2 = t2->get_pos();
3479 Point2d pp = { std::min(p.
x,p2.
x), std::min(p.
y,p2.
y) };
3480 Point2d pp2 = { std::max(p.
x,p2.
x), std::max(p.
y,p2.
y) };
3481 Vector2d sz = pp2-pp;
3493 ev.shader_api.use(sh);
3494 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.identity());
3496 ev.polygon_api.render_vertex_array(line_3);
3497 ev.shader_api.use(sh2);
3507 int delta2_x, delta2_y;
3518class LineWidget2 :
public GuiWidgetForward
3521 LineWidget2(GameApi::Env &
env, GameApi::EveryApi &
ev, GameApi::SH sh, GuiWidget *t1,
int delta_x,
int delta_y,
3522 GuiWidget *t2,
int delta2_x,
int delta2_y, GameApi::SH sh2)
3524 t2(t2), delta2_x(delta2_x), delta2_y(delta2_y),sh2(sh2) { firsttime =
true;
3525 Point2d p = t1->get_pos();
3528 Point2d p2 = t2->get_pos();
3531 Point2d pp = { std::min(p.
x,p2.
x), std::min(p.
y,p2.
y) };
3532 Point2d pp2 = { std::max(p.
x,p2.
x), std::max(p.
y,p2.
y) };
3533 Vector2d sz = pp2-pp;
3536 Vector2d
d = { 0.0, 0.0 };
3539 void set_pos(Point2d p2)
3544 Point2d p = { -666.0, -666.0 };
3548 GameApi::PT
line_func(
int linenum,
bool id)
3551 return ev.point_api.point(100.0,0.0,0.0);
3552 return ev.point_api.point(0.0,0.0,0.0);
3554 GameApi::P line_to_poly(
int i,
float sx,
float sy,
float sz,
float ex,
float ey,
float ez,
unsigned int scolor,
unsigned int ecolor)
3558 GameApi::PT p1 =
ev.point_api.point(sx,sy,0.0);
3559 GameApi::PT p2 =
ev.point_api.point(sx,sy+width,0.0);
3560 GameApi::PT p3 =
ev.point_api.point(ex,ey,0.0);
3561 GameApi::PT p4 =
ev.point_api.point(ex,ey+width,0.0);
3562 GameApi:: P poly =
ev.polygon_api.quad(p1,p2,p3,p4);
3564 return ev.polygon_api.color(poly, 0xffffffff);
3566 void update(Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
3568 using std::placeholders::_1;
3569 using std::placeholders::_2;
3570 using std::placeholders::_3;
3571 using std::placeholders::_4;
3572 using std::placeholders::_5;
3573 using std::placeholders::_6;
3574 using std::placeholders::_7;
3575 using std::placeholders::_8;
3576 using std::placeholders::_9;
3579 line =
ev.lines_api.function([
this](
int a,
bool b){
return line_func(a,b); }, 1);
3580 line =
ev.lines_api.change_color(line, 0xffffffff);
3581 line_2 =
ev.polygon_api.from_lines(line, [
this](
int a,
float b,
float c,
float d,
float e,
float f,
float g,
unsigned int h,
unsigned int i) {
return line_to_poly(a,b,c,
d,
e,
f,g,h,i); });
3582 line_3 =
ev.polygon_api.create_vertex_array(line_2,
true);
3589 if (old_t1_pos.x != t1->get_pos().x ||old_t2_pos.x != t2->get_pos().x
3590 ||old_t1_pos.y != t1->get_pos().y || old_t2_pos.y != t2->get_pos().y)
3592 line =
ev.lines_api.function([
this](
int a,
bool b){
return line_func(a,b); }, 1);
3593 line =
ev.lines_api.change_color(line, 0xffffffff);
3594 line_2 =
ev.polygon_api.from_lines(line, [
this](
int a,
float b,
float c,
float d,
float e,
float f,
float g,
unsigned int h,
unsigned int i) {
return line_to_poly(a,b,c,
d,
e,
f,g,h,i); });
3597 ev.polygon_api.update_vertex_array_no_memory(line_3, line_2);
3602 old_t1_pos = t1->get_pos();
3603 old_t2_pos = t2->get_pos();
3606 Point2d p = t1->get_pos();
3610 Point2d p2 = t2->get_pos();
3614 Point2d pp = { std::min(p.
x,p2.
x), std::min(p.
y,p2.
y) };
3615 Point2d pp2 = { std::max(p.
x,p2.
x), std::max(p.
y,p2.
y) };
3616 Vector2d sz = pp2-pp;
3628 ev.shader_api.use(sh);
3629 Point2d p = t1->get_pos();
3633 Point2d p2 = t2->get_pos();
3637 LineProperties prop(Point(p.
x,p.
y,0.0), Point(p2.
x,p2.
y,0.0));
3639 Matrix m1 = prop.translate_to_p1();
3640 Matrix m2 = prop.rotate_z_from_p1_in_2d();
3641 Matrix m3 = prop.scale_length_in_2d();
3642 Matrix mm = m0*m3*m2*m1;
3644 ev.shader_api.set_var(sh,
"in_MV", mm2);
3646 ev.polygon_api.render_vertex_array(line_3);
3647 ev.shader_api.use(sh2);
3658 int delta2_x, delta2_y;
3701 ToolTipData *dt = (ToolTipData*)
data;
3702 GameApi::W w = dt->api->
text(dt->label, dt->atlas, dt->atlas_bm, dt->x_gap);
3706 float p_x = dt->api->
pos_x(dt->orig) + dt->api->
size_x(dt->orig) + 10.0;
3707 float p_y = dt->api->
pos_y(dt->orig) + 10.0;
3708 dt->api->
set_pos(w3, p_x, p_y);
3714 ToolTipData *dt =
new ToolTipData;
3717 dt->insert = insert;
3720 dt->atlas_bm = atlas_bm;
3728 W target2,
int delta2_x,
int delta2_y,
SH sh,
SH old_sh)
3733 t2, delta2_x, delta2_y, old_sh));
3764 int s =
env->widgets.size();
3765 for(
int i=0;i<s;i++)
3784 if (!canvas_2)
return -1;
3787 return canvas_2->
count()-1;
3797 if (!canvas_2)
return;
3808 if (!canvas_2)
return -1;
3814 W node_t =
text(label, atlas, atlas_bm);
3815 W node_t0 =
margin(node_t, 5,5,5,5);
3818 W node_1 =
layer(node_0, node_t0);
3823EXPORT GameApi::W GameApi::GuiApi::list_item_opened(
int sx, std::string label,
FtA atlas,
BM atlas_bm, std::vector<std::string> subitems, std::vector<std::string> subitems_tooltip,
FtA atlas2,
BM atlas_bm2,
W insert,
bool hide,
W *redraw_w, std::vector<std::string> subitems_funcname)
3827 vec.push_back(title);
3828 int s = subitems.size();
3829 std::vector<W> w_vec;
3830 for(
int i=0;i<s;i++)
3834 std::string label = subitems[i];
3835 std::string toolt = label +
"::" + subitems_tooltip[i];
3838 int s2 = label.size();
3839 for(
int j=0;j<s2;j++) {
3841 GameApi::BM txt_0=ev.font_api.font_string_from_atlas(ev,atlas2,atlas_bm2,label2,3*1.2);
3842 int sz = ev.bitmap_api.size_x(txt_0);
3845 if (label2 != label) {
3846 if (label2.size()>2) label2=label2.substr(0,label2.size()-2);
3849 }
else { label2=label; }
3850 W txt_0 =
text(label2, atlas2, atlas_bm2);
3853 W txt_21 =
tooltip(txt_2, insert, toolt, atlas2, atlas_bm2, 2, 40.0);
3854 txt_3 =
layer(txt_1, txt_21);
3856 vec.push_back(txt_4);
3857 w_vec.push_back(txt_4);
3860 W array_2 =
margin(array, 1,1,1,1);
3861 if (
hide) array_2 = title;
3874 WindowMoveWidget(
GameApi::EveryApi &
ev,
GuiWidget *wid,
int area_x,
int area_y,
int area_width,
int area_height) :
GuiWidgetForward(
ev, { wid } ), area_x(area_x), area_y(area_y), area_width(area_width), area_height(area_height) { move_ongoing =
false;
3875 Point2d p = { -666.0, -666.0 };
3876 update(p, -1, -1, -1, 0);
3878 void update(
Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
3881 if (!move_ongoing && button==0 && type==1025 && mouse.
x >= pos.
x+area_x && mouse.
x < pos.
x+area_x+area_width &&
3882 mouse.
y >= pos.
y+area_y && mouse.
y < pos.
y+area_y+area_height)
3884 move_ongoing =
true;
3890 Point2d p = { float(px), float(py) };
3894 Vector2d delta = mouse - old_mouse;
3901 if (move_ongoing && button==-1)
3903 move_ongoing =
false;
3905 size = vec[0]->get_size();
3907 int chosen_item()
const {
return vec[0]->chosen_item(); }
3910 int area_width, area_height;
3916class MouseMoveWidget :
public GuiWidgetForward
3919 MouseMoveWidget(GameApi::EveryApi &
ev, GuiWidget *wid,
int area_x,
int area_y,
int area_width,
int area_height) : GuiWidgetForward(
ev, { wid } ), area_x(area_x), area_y(area_y), area_width(area_width), area_height(area_height) { move_ongoing =
false;
3920 Point2d p = { -666.0, -666.0 };
3923 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
3926 if (!move_ongoing && button==0 && type==1025 && mouse.
x >= pos.
x+area_x && mouse.
x < pos.
x+area_x+area_width &&
3927 mouse.
y >= pos.
y+area_y && mouse.
y < pos.
y+area_y+area_height)
3929 move_ongoing =
true;
3934 Vector2d delta = mouse - old_mouse;
3935 Point2d p = old_pos + delta;
3938 if (move_ongoing && button==-1)
3940 move_ongoing =
false;
3943 size = vec[0]->get_size();
3945 void set_cb(
void (*p_fptr)(
void*),
void* p_data) { }
3946 int chosen_item()
const {
return vec[0]->chosen_item(); }
3949 int area_width, area_height;
3959 MouseMoveWidget *w2 = (MouseMoveWidget*)w;
3960 w2->set_cb(fptr,
data);
3964class RectangleWidget :
public GuiWidgetForward
3967 RectangleWidget() =
delete;
3968 RectangleWidget(GameApi::EveryApi &
ev, GameApi::SH sh,
int start_x,
int end_x,
int start_y,
int end_y,
unsigned int color) : GuiWidgetForward(
ev, { } ), sh(sh), start_x(start_x), end_x(end_x), start_y(start_y), end_y(end_y),
color(
color) {
3970 Point2d p = { -666.0, -666.0 };
3973 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
3976 Vector2d sz = { float(end_x-start_x), float(end_y-start_y) };
3982 GameApi::BB b =
ev.bool_bitmap_api.bb_empty(sx,sy);
3983 GameApi::BB b1 =
ev.bool_bitmap_api.rectangle(b, 0.0, 0.0,
float(sx),
float(sy));
3985 bg =
ev.bool_bitmap_api.to_bitmap(b1, c.r,c.g,c.b,c.alpha,0,0,0,0);
3986 bg_va =
ev.sprite_api.create_vertex_array(bg);
3996 Point2d p = get_pos();
3997 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x, p.
y, 0.0));
3998 ev.sprite_api.render_sprite_vertex_array(bg_va);
4016 return add_widget(e,
new RectangleWidget(ev,sh,start_x, end_x, start_y, end_y,
color));
4022 ClickAreaWidget(
GameApi::EveryApi &
ev,
GuiWidget *wid,
int area_x,
int area_y,
int area_width,
int area_height,
int button_id2) :
GuiWidgetForward(
ev, { wid } ), area_x(area_x), area_y(area_y), area_width(area_width), area_height(area_height) {
done=
false;
4024 button_id = button_id2;
4025 Point2d p = { -666.0, -666.0 };
4028 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
4032 if (
done) selected=
false;
4033 if (button==-1) {
done =
false; }
4037 if (!
done && button==button_id && type==1025 && mouse.
x >= pos.
x+area_x && mouse.
x < pos.
x+area_x+area_width &&
4038 mouse.
y >= pos.
y+area_y && mouse.
y < pos.
y+area_y+area_height)
4044 size = vec[0]->get_size();
4046 int chosen_item()
const {
if (selected) { selected=
false;
return 0; }
else return -1; }
4049 int area_width, area_height;
4050 mutable bool selected;
4055class KeyAreaWidget :
public GuiWidgetForward
4058 KeyAreaWidget(GameApi::EveryApi &
ev, GuiWidget *wid,
int area_x,
int area_y,
int area_width,
int area_height,
int key) : GuiWidgetForward(
ev, { wid } ), area_x(area_x), area_y(area_y), area_width(area_width), area_height(area_height),key(key) {
done=
false;
4059 Point2d p = { -666.0, -666.0 };
4063 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
4067 if (
done) {selected=
false; }
4068 if (ch==-1) {
done =
false; }
4072 if (!
done && ch==key && type==768 && mouse.
x >= pos.
x+area_x && mouse.
x < pos.
x+area_x+area_width &&
4073 mouse.
y >= pos.
y+area_y && mouse.
y < pos.
y+area_y+area_height)
4079 size = vec[0]->get_size();
4081 int chosen_item()
const {
if (selected)
return 0;
else return -1; }
4084 int area_width, area_height;
4094 return add_widget(e,
new ClickAreaWidget(ev, wid, area_x, area_y, area_width, area_height,button_id));
4100 return add_widget(e,
new KeyAreaWidget(ev, wid, area_x, area_y, area_width, area_height, key));
4107 return add_widget(e,
new MouseMoveWidget(ev, wid, area_x, area_y, area_width, area_height));
4113 return add_widget(e,
new WindowMoveWidget(ev, wid, area_x, area_y, area_width, area_height));
4119 int s = return_type.size();
4122 for(
int i=0;i<s;i++) {
4123 if (return_type[i]==
'[') level++;
4124 if (return_type[i]==
']') level--;
4125 if (return_type[i]==
',' && level==0) count++;
4129std::string ret_type_index(std::string return_type,
int index)
4131 int s = return_type.size();
4138 if (return_type[i]==
'[') level++;
4139 if (return_type[i]==
']') level--;
4140 if (return_type[i]==
',' && level==0) {
4141 label = return_type.substr(beg,i-beg);
4142 if (count==index)
return label;
4147 label = return_type.substr(beg,i-beg);
4154 W label =
text(filename, atlas2,atlas_bm2);
4155 W author_label =
text(
"Author:", atlas, atlas_bm);
4156 static std::string expr;
4157 static W redraw_w =
empty();
4158 W author_edit =
string_editor(
"abcdefghijklmnopqrstuvwxyz\xE5\xE4\xF6 ABCDEFGHIJKLMNOPQRSTUVWXYZ\xC5\xC4\xD6 1234567890-_*^@£$!#¤%&/()=? ", author_name, expr, atlas, atlas_bm,0,0,&redraw_w);
4159 W arr_x[] = { author_label, author_edit };
4160 W author_x =
array_x(&arr_x[0], 2, 0);
4161 W author_marg =
margin(author_x,5,0,0,0);
4162 W license_label =
text(
"License:", atlas, atlas_bm);
4163 static std::string expr2;
4164 W edit =
url_editor(license_url, atlas, atlas_bm, 3, expr2);
4165 W arr_x2[] = { license_label, edit };
4166 W license_x =
array_x(&arr_x2[0],2,0);
4167 W marg =
margin(license_x,5,0,0,0);
4168 std::vector<W> arr0;
4169 arr0.push_back(label);
4170 arr0.push_back(author_marg);
4171 arr0.push_back(marg);
4179 W label =
text(jpg_display_name, atlas,atlas_bm);
4180 W label_margin =
margin(label, 120, 15, 15, 15);
4181 BM bm = ev.bitmap_api.loadbitmapfromurl(jpg_url);
4182 BM bm2 = ev.bitmap_api.scale_bitmap(ev, bm, 30, 30);
4183 W icon_contents =
icon(bm2);
4184 W icon_margin =
margin(icon_contents, 15,5,120+15,5);
4186 vec.push_back(label_margin);
4187 vec.push_back(icon_margin);
4194 int s = std::min(jpg_urls.size(),jpg_display_names.size());
4196 for(
int i=0;i<s;i++)
4198 W item =
asset_item(ev,jpg_urls[i], jpg_display_names[i],atlas, atlas_bm);
4199 vec.push_back(item);
4212 xx.push_back(scrollbar);
4219 W marg =
margin(arr_xx, mx,my,mx,my2);
4223 W but_1 =
text(
"Select", atlas, atlas_bm);
4228 W but_5 =
layer(but_41, but_3);
4230 select_button = but_6;
4232 W code_1 =
text(
"Cancel", atlas, atlas_bm);
4237 W code_5 =
layer(code_41, code_3);
4239 cancel_button = code_6;
4241 W arr_x[] = { code_6, but_6 };
4242 W arr_x2 =
array_x(&arr_x[0], 2, 0);
4244 std::vector<W> arr_y = { bm_4, arr_x2 };
4248 W lay =
layer(rect,arr_2);
4256EXPORT GameApi::W GameApi::GuiApi::license_dialog(std::vector<std::string> filename, std::vector<std::string> &license_url, std::vector<std::string> &author_name,
FtA atlas,
BM atlas_bm,
FtA atlas2,
BM atlas_bm2,
FtA atlas3,
BM atlas_bm3,
W &next_button,
W &cancel_button,
W &canvas2,
W &canvas_area2,
W &scroll_bar)
4258 int s = std::min(filename.size(),license_url.size());
4260 for(
int i=0;i<s;i++)
4262 W item =
license_item(filename[i],license_url[i],author_name[i], atlas, atlas_bm,atlas3, atlas_bm3);
4263 vec.push_back(item);
4270 scroll_bar = scrollbar;
4276 xx.push_back(scrollbar);
4283 W marg =
margin(arr_xx, mx,my,mx,my2);
4287 W but_1 =
text(
"Next->", atlas3, atlas_bm3);
4294 W but_5 =
layer(but_41, but_3);
4298 next_button = but_6;
4300 W code_1 =
text(
"Cancel", atlas3, atlas_bm3);
4305 W code_5 =
layer(code_41, code_3);
4307 cancel_button = code_6;
4309 W arr_x[] = { code_6, but_6 };
4310 W arr_x2 =
array_x(&arr_x[0], 2, 0);
4312 std::vector<W> arr_y = { bm_4, arr_x2 };
4316 W lay =
layer(rect,arr_2);
4328 std::vector<std::string> prog;
4329 std::vector<std::string> rest;
4331 int s2 = vec.size();
4332 for(
int i=0;i<s2;i++)
4334 if (vec[i].
size()>19) {
4335 std::string r = vec[i].substr(18);
4337 if (r!=
" loading assets" && r!=
" collect") {
4338 prog.push_back(vec[i].substr(0,18));
4339 rest.push_back(vec[i].substr(18));
4345 while(rest.size()<3) { restcount++; rest.push_back(
"Caaaaaaaaaaaaaaaaaaaa"); }
4351 int s3 = std::max(0,
int(rest.size()));
4352 int start = std::max(s3-3,0);
4355 for(
int ii=start;ii<s3;ii++)
4359 int s = rest[ii].size();
4360 for(
int i=0;i<s;i++)
4362 if (rest[ii][i]==
'.') pos=i;
4366 int restsize = rest[ii].size()-pos;
4367 if (pos!=-1 && pos >25-restsize)
4369 std::string start = rest[ii].substr(0,25-restsize);
4370 std::string rest2 = rest[ii].substr(pos);
4371 rest[ii] = start+rest2;
4380BB I1=ev.bool_bitmap_api.bb_empty(310,40);
4381BB I2=ev.bool_bitmap_api.rectangle(I1,0,0,310,2);
4382BB I3=ev.bool_bitmap_api.rectangle(I2,0,0,2,40);
4383BB I4=ev.bool_bitmap_api.rectangle(I3,0,38,310,2);
4384BB I5=ev.bool_bitmap_api.rectangle(I4,308,0,2,40);
4385BM I6=ev.bool_bitmap_api.to_bitmap(I5,255,255,255,255,0,0,0,0);
4386BB I7=ev.bool_bitmap_api.bb_empty(300,30);
4388 BB I8=ev.bool_bitmap_api.rectangle(I7,0,0,300*val/max,30);
4389BM I9=ev.bool_bitmap_api.to_bitmap(I8,255,255,255,255,0,0,0,0);
4390BM I10=ev.bitmap_api.blitbitmap(I6,I9,5,5);
4398 arr.push_back(txt_0);
4425 W txt_4 =
layer(rect, array_1);
4442 static int g_id = -1;
4454EXPORT GameApi::W GameApi::GuiApi::canvas_item_gameapi_node(
int sx,
int sy, std::string label, std::vector<std::string> param_types, std::vector<std::string> param_tooltip, std::string return_type,
FtA atlas,
BM atlas_bm, std::vector<W *> connect_click, std::string uid, std::vector<W> ¶ms, std::string symbol, std::string comment)
4457 int s = param_types.size();
4459 for(
int i=0;i<s;i++)
4461 std::string p = param_types[i];
4462 std::string tt = param_tooltip[i];
4463 W txt_0 =
text(p, atlas, atlas_bm);
4464 W txt_1 =
margin(txt_0, 5,5,5,5);
4465 W txt_11 =
tooltip(txt_1, txt_1, tt, atlas, atlas_bm, 2, 0.0);
4466 int width =
size_x(txt_1);
4469 W txt_3 =
layer(txt_2, txt_11);
4472 std::stringstream ii;
4474 std::string param_uid = uid +
" " + ii.str();
4476 set_id(txt_4, param_uid);
4477 params.push_back(txt_4);
4478 vec.push_back(txt_4);
4481 W node_2 =
text(label, atlas,atlas_bm);
4482 W node_2a =
text(symbol, atlas,atlas_bm);
4487 W node_2b =
tooltip(node_2a, node_2a, comment, atlas, atlas_bm,2,0.0);
4488 W node_2bb =
layer(node_2a, node_2b);
4489 std::vector<W> arr = { node_2, node_2bb };
4490 W node_2c =
array_x(&arr[0],arr.size(),5);
4491 W node_22 =
margin(node_2c, 5,5,5,5);
4494 int ssy = std::max(sy,
size_y(array)+
size_y(node_22)+5);
4495 int ssy0 = std::max(sy-
size_y(node_22),
size_y(array));
4496 int ssy2 = ssy0 -
size_y(array);
4501 std::vector<W> vec_ret;
4503 for(
int j=0;j<rs;j++) {
4504 std::string ret_type = ret_type_index(return_type,j);
4505 W txt_0 =
text(ret_type, atlas,atlas_bm);
4506 W txt_1 =
margin(txt_0, 5,5,5,5);
4508 int max_width2 =
size_x(txt_1);
4514 *(connect_click[j]) = txt_111;
4517 W txt_3 =
layer(txt_2, txt_111);
4519 ret_sx = std::max(
size_x(txt_3),ret_sx);
4521 vec_ret.push_back(txt_3);
4523 for(
int j=0;j<rs;j++)
4525 vec_ret[j] =
margin(vec_ret[j], ret_sx-
size_x(vec_ret[j]),0.0, 0.0, 0.0);
4527 int max_width2 = ret_sx;
4528 W array_ret =
array_y(vec_ret , 5);
4529 int ret_sy =
size_y(array_ret);
4534 ssy = std::max(ssy,
size_y(array_ret)+
size_y(node_22)+5);
4535 ssy0 = std::max(ssy0,
size_y(array_ret));
4536 ssy2 = ssy0 - std::max(
size_y(array),
size_y(array_ret));
4540 int ssx_0 = std::max(sx,
max_width+4+20+4+max_width2);
4541 int ssx = std::max(ssx_0,
size_x(node_22));
4552 W l_0 =
layer(node_0, node_12);
4553 W l_1 =
layer(l_0, node_22);
4554 W l_2 =
layer(l_1, array_1);
4555 W l_3 =
layer(l_2, txt_4);
4574 std::vector<GuiWidget*> vec2;
4576 for(
int i=0;i<s;i++)
4593 static std::string expr =
"@";
4594 W editor_t =
string_editor(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_@",
g_searchstring, expr, atlas,atlas_bm,x_gap,1,redraw_w,
false);
4595 W node_t0 =
margin(editor_t, 5,5,5,5);
4616 std::vector<GuiWidget*> items2;
4617 int s = items.size();
4618 for(
int i=0;i<s;i++)
4629 std::vector<GuiWidget*> vec2;
4631 for(
int i=0;i<s;i++)
4646EXPORT GameApi::W GameApi::GuiApi::dynamic_text(std::string need_letters, std::string *dyn_text,
void (*fptr)(
void*,
float mouse_x,
float mouse_y,
int button,
int ch,
int type,
int mouse_wheel_y),
void *user_ptr,
GameApi::FtA atlas,
GameApi::BM atlas_bm,
int x_gap)
4649 return add_widget(e,
new DynamicTextGuiWidget(e,ev,*
this, need_letters,dyn_text,fptr,user_ptr,atlas,atlas_bm,x_gap));
4672 return add_widget(e,
new IconGuiWidget(ev, bm,sh));
4677 return add_widget(e,
new IconGuiWidgetSharedNoScale(e,ev, bm, sh, key));
4688 return add_widget(e,
new IconGuiWidgetShared(e,ev, bm, sh, key));
4697 return add_widget(e,
new PolyGuiWidget(ev, p, sh2, sh, sx,sy, screen_size_x, screen_size_y));
4701 return add_widget(e,
new VAGuiWidget(ev, p, sh2, sh, sx,sy, screen_size_x, screen_size_y));
4709 for(
int i=0;i<s;i++)
4715 return add_widget(e,
new MLGuiWidget(e, ev, p, sh2, sh3, sh_2d, sh_arr, sh, sx,sy, screen_size_x, screen_size_y));
4719 return add_widget(e,
new ShaderPlaneGuiWidget(ev, p, sh, sx,sy,screen_x, screen_y));
4724 return add_widget(e,
new LinesGuiWidget(ev, p, sh2, sh, sx,sy, screen_size_x, screen_size_y));
4728 return add_widget(e,
new PTSGuiWidget(e,ev, p, sh2, sh, sx,sy, screen_size_x, screen_size_y));
4734 W e1 =
add_widget(e,
new EditorGuiWidgetAtlas<std::string>(e,ev, allowed_chars, target, atlas, atlas_bm, sh, x_gap, allow_expr, expr,non_editable_char_count,redraw_w));
4751 std::string allowed_chars =
"0123456789.-+*/%@";
4753 W w =
add_widget(e,
new EditorGuiWidgetAtlas<float>(e,ev,allowed_chars, target, atlas, atlas_bm, sh, x_gap,
true, expr,noneditnum ,&ww));
4762 std::string allowed_chars=
"";
4764 std::string allowed_chars =
"0123456789.-abcdefghijklmnopqrstuvwxyz\xE5\xE4\xF6 246ABCDEFGHIJKLMNOPQRSTUVWXYZ\xC5\xC4\xD6~!\"#€%&/()=?+\\*^.,-<>|§œ;:_$@";
4769 W w =
add_widget(e,
new EditorGuiWidgetAtlas<std::string>(e,ev,allowed_chars, target, atlas, atlas_bm, sh, x_gap,
true,expr,noneditnum,&ww));
4776std::vector<std::string> parse_array(std::string s);
4777std::vector<std::string> parse_enum_type(std::string type)
4779 if (type.size()>2) {
4780 if (type[0]==
'{' && type[type.size()-1]==
'}')
4782 std::string rest = type.substr(1,type.size()-2);
4783 return parse_array(rest);
4786 return std::vector<std::string>();
4789std::map<int, int> enum_map;
4796 std::vector<std::string> arr = parse_enum_type(type);
4797 if (target<0||target>=arr.size()) {
GameApi::W w; w.
id = -1;
return w; }
4804 W w =
int_editor(target, expr, atlas, atlas_bm, x_gap,noneditnum);
4806 std::string filename;
4808 filename=
"arrow.ppm";
4810 filename=
"/usr/share/arrow.ppm";
4812 BM bm = ev.bitmap_api.loadbitmap(filename);
4816 enum_map[click.
id]=w.id;
4817 click_widget = click;
4818 std::stringstream ss;
4820 set_id(click_widget,ss.str());
4822 std::vector<W> vec = { w, layer2 };
4823 W arr2 =
array_x(&vec[0],vec.size(), 5);
4826static bool enum_clicked=
false;
4829IMPORT bool enum_editor_callback(
GameApi::Env &
env,
GameApi::GuiApi &gui,
GameApi::W click_widget, std::string type,
int mouse_x,
int mouse_y,
GameApi::FtA atlas,
GameApi::BM atlas_bm,
int x_gap, std::vector<GameApi::W> &areas,
int button,
int type2)
4833 if (enum_clicked==
true){
4835 if (button==0&&type2==1025) {
4847 p->
update(pp,0,-1,-1,-1);
4849 std::vector<std::string> arr = parse_enum_type(type);
4851 for(
int i=0;i<s;i++) {
4852 std::stringstream ss;
4853 ss << i <<
":" << arr[i];
4856 areas=std::vector<GameApi::W>();
4873 for(
int i=0;i<s;i++) {
4875 if (w.id==0)
continue;
4876 std::string val = gui.
get_id(w);
4888extern std::map<int,int> int_editor_map;
4893 std::string val = w->get_id();
4895 std::stringstream ss(val);
4898 ss >> ch1 >> ch2 >> std::hex >> ptr;
4899 int *ptr2 = (
int*)ptr;
4904 editor2.
id = int_editor_map[
editor.id];
4907 std::stringstream ss2;
4913 ed->set_value(ss2.str());
4915 ed->
update(pp,-1,-1,-1,-1);
4921std::map<int, int> int_editor_map;
4926 std::string allowed_chars =
"0123456789-&%";
4928 W w =
add_widget(e,
new EditorGuiWidgetAtlas<int>(e,ev, allowed_chars, target, atlas, atlas_bm, sh, x_gap,
true,expr,noneditnum,&ww));
4931 int_editor_map[w2.id]=w.id;
4939 std::string allowed_chars =
"0123456789-";
4943 W w =
add_widget(e,
new EditorGuiWidgetAtlas<long>(e,ev, allowed_chars, target, atlas, atlas_bm, sh, x_gap,
false,expr,noneditnum,&ww));
4953 std::string allowed_chars =
"0123456789abcdef";
4955 static W redraw_w =
empty();
4956 W edit =
string_editor(allowed_chars, col, expr, atlas, atlas_bm, x_gap,noneditnum,&redraw_w);
4964 std::string allowed_chars=
"";
4966 std::string allowed_chars=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#€%&/()=?\\|<>,.-;:_^~*'åöäÅÖÄ+";
4970 W bm_2 =
margin(w, 10,10,10,10);
4972 W bm_4 =
layer(bm_3, bm_2);
4974 W but_1 =
text(
"Close", atlas, atlas_bm);
4979 W but_5 =
layer(but_41, but_3);
4981 close_button = but_6;
4993 std::vector<W> arr = { bm_4, but_6 };
5004 int s = dir_items.size();
5006 for(
int i=0;i<s;i++)
5008 W txt =
text(dir_items[i], atlas, atlas_bm);
5011 clicks.push_back(txt_click);
5012 vec.push_back(txt_click);
5028 if (titles.size()==0)
5030 std::vector<W> vert;
5034 int s = titles.size();
5035 std::vector<W> horiz_bar;
5036 for(
int i=0;i<s;i++)
5038 W txt =
text(titles[i], atlas, atlas_bm);
5039 W txt2 =
margin(txt,10,10,10,10);
5042 buttons.push_back(txt_click);
5044 W close_button2 =
text(
"x", atlas, atlas_bm);
5045 W close_button21 =
margin(close_button2,2,2,2,25);
5048 close_button.push_back(close_click);
5049 std::vector<W> horiz_tab;
5050 horiz_tab.push_back(txt_click);
5051 horiz_tab.push_back(close_click);
5052 W arr_tab =
array_x(&horiz_tab[0], horiz_tab.size(), 3);
5055 float percentage = 0.0;
5056 if (progress[i]>0.0)
5058 percentage = progress[i];
5060 W perc_button =
button(
size_x(arr_tab)*percentage,
size_y(arr_tab),i==active_tab?0xff00ff00:0xff008800, i==active_tab?0xff00ff00:0xff008800);
5062 W tab_button =
button(
size_x(arr_tab),
size_y(arr_tab),i==active_tab?0xff004400:0xff002200, i==active_tab?0xff004400:0xff002200);
5063 W back_layer =
layer(tab_button, perc_button);
5064 W tab_layer =
layer(back_layer, arr_tab);
5066 horiz_bar.push_back(tab_layer);
5069 W arr_top =
array_x(&horiz_bar[0], horiz_bar.size(), 3);
5070 std::vector<W> vert;
5071 vert.push_back(arr_top);
5074 W comb_but =
button(ev.mainloop_api.get_screen_width(),
size_y(arr_combine),0xff228822, 0xff081108);
5075 W comb_layer =
layer(comb_but,arr_combine);
5078 W arr_top2 =
margin(comb_layer, 0,ev.mainloop_api.get_screen_height()-
size_y(comb_layer),0,0);
5082EXPORT GameApi::W GameApi::GuiApi::navi_bar(
GameApi::EveryApi &ev, std::vector<std::string> titles,
W &back_button,
W &forward_button,
W &save_button, std::string &
url,
W &url_button, std::vector<W> &close_button, std::vector<W> &tab_change_button,
W &new_tab_button, std::vector<std::string> bookmark_labels, std::vector<std::string> bookmark_urls,
FtA atlas,
BM atlas_bm,
int &active_tab)
5085 int s = titles.size();
5086 std::vector<W> horiz_bar;
5087 for(
int i=0;i<s;i++)
5089 W txt =
text(titles[i], atlas, atlas_bm);
5090 W txt2 =
margin(txt,10,10,10,10);
5093 tab_change_button.push_back(txt_click);
5094 W close_button2 =
text(
"x", atlas, atlas_bm);
5095 W close_button21 =
margin(close_button2,2,2,2,25);
5098 close_button.push_back(close_click);
5099 std::vector<W> horiz_tab;
5100 horiz_tab.push_back(txt_click);
5101 horiz_tab.push_back(close_click);
5102 W arr_tab =
array_x(&horiz_tab[0], horiz_tab.size(), 3);
5104 W tab_layer =
layer(tab_button, arr_tab);
5105 horiz_bar.push_back(tab_layer);
5107 W new_tab_button2 =
text(
"+", atlas, atlas_bm);
5108 W new_tab_button3 =
margin(new_tab_button2,10,10,10,10);
5109 W new_tab_button4 =
highlight(new_tab_button3);
5111 new_tab_button = new_tab_click;
5112 horiz_bar.push_back(new_tab_click);
5114 W arr_top =
array_x(&horiz_bar[0], horiz_bar.size(), 3);
5120 std::vector<W> horiz_bar2;
5121 W back_button2 =
text(
"<-", atlas, atlas_bm);
5122 W back_button3 =
margin(back_button2,10,15,10,15);
5125 W back_layer =
layer(back_button4, back_button31);
5128 back_button = back_click;
5129 W forward_button2 =
text(
"->", atlas, atlas_bm);
5130 W forward_button3 =
margin(forward_button2,10,15,10,15);
5131 W forward_button31 =
highlight(forward_button3);
5133 W forward_layer =
layer(forward_button4, forward_button31);
5137 forward_button = forward_click;
5139 W save_button2 =
text(
"[]", atlas, atlas_bm);
5140 W save_button3 =
margin(save_button2,10,10,10,10);
5143 W save_layer =
layer(save_button4, save_button31);
5147 static std::string expr;
5149 W url_bar2 =
center_y(url_bar, 20+5+20-2-2-1);
5150 W url_bar21 =
size(url_bar2, 630,20+5+20-2-2-1);
5151 W url_bar3 =
margin(url_bar21,30,0,0,0);
5154 W url_bar_layer =
layer(url_bar4, url_bar31);
5157 horiz_bar2.push_back(back_click);
5158 horiz_bar2.push_back(forward_click);
5159 horiz_bar2.push_back(save_click);
5160 horiz_bar2.push_back(url_bar_layer);
5161 W arr_middle =
array_x(&horiz_bar2[0], horiz_bar2.size(), 6);
5164 std::vector<W> vert;
5165 vert.push_back(arr_top);
5169 W comb_but =
button(ev.mainloop_api.get_screen_width(),
size_y(arr_combine),0xff228822, 0xff081108);
5170 W comb_layer =
layer(comb_but,arr_combine);
5186 W bm_1 =
poly(p, sh, w,h, screen_size_x,screen_size_y);
5188 W bm_2 =
margin(bm_1, 10,10,10,10);
5190 W bm_4 =
layer(bm_3, bm_2);
5192 W but_1 =
text(
"Close", atlas, atlas_bm);
5197 W but_5 =
layer(but_41, but_3);
5199 close_button = but_6;
5201 W code_1 =
text(
"CodeGen", atlas, atlas_bm);
5206 W code_5 =
layer(code_41, code_3);
5208 codegen_button = code_6;
5210 W coll_1 =
text(
"Edit", atlas, atlas_bm);
5215 W coll_5 =
layer(coll_41, coll_3);
5217 collect_button = coll_6;
5220 W arr_x[] = { code_6, coll_6, but_6 };
5221 W arr_x2 =
array_x(&arr_x[0], 3, 0);
5225 std::vector<W> arr = { bm_4, arr_x2 };
5244 W bm_1 =
va(p, sh, w,h, screen_size_x,screen_size_y);
5245 W bm_2 =
margin(bm_1, 10,10,10,10);
5247 W bm_4 =
layer(bm_3, bm_2);
5249 W but_1 =
text(
"Close", atlas, atlas_bm);
5254 W but_5 =
layer(but_41, but_3);
5256 close_button = but_6;
5258 W code_1 =
text(
"CodeGen", atlas, atlas_bm);
5263 W code_5 =
layer(code_41, code_3);
5265 codegen_button = code_6;
5268 std::vector<W> arr = { bm_4, code_6, but_6 };
5275EXPORT GameApi::W GameApi::GuiApi::ml_dialog(
ML p,
SH sh,
SH sh2,
SH sh_2d,
SH sh_arr,
int screen_size_x,
int screen_size_y,
W &close_button,
FtA atlas,
BM atlas_bm,
W &codegen_button,
W &collect_button)
5288 W bm_1 =
ml(p, sh, sh2, sh_2d, sh_arr, w,h, screen_size_x,screen_size_y);
5289 W bm_2 =
margin(bm_1, 10,10,10,10);
5291 W bm_4 =
layer(bm_3, bm_2);
5293 W but_1 =
text(
"Close", atlas, atlas_bm);
5298 W but_5 =
layer(but_41, but_3);
5300 close_button = but_6;
5302 W code_1 =
text(
"CodeGen", atlas, atlas_bm);
5307 W code_5 =
layer(code_41, code_3);
5309 codegen_button = code_6;
5312 std::vector<W> arr = { bm_4, code_6, but_6 };
5336 W bm_2 =
margin(bm_1, 10,10,10,10);
5338 W bm_4 =
layer(bm_3, bm_2);
5340 W but_1 =
text(
"Close", atlas, atlas_bm);
5345 W but_5 =
layer(but_41, but_3);
5347 close_button = but_6;
5349 W code_1 =
text(
"CodeGen", atlas, atlas_bm);
5354 W code_5 =
layer(code_41, code_3);
5356 codegen_button = code_6;
5359 std::vector<W> arr = { bm_4, code_6, but_6 };
5377 W txt =
text(label, atlas, atlas_bm,3);
5378 W txt_1 =
margin(txt, 5,7,5,5);
5379 W but_1 =
button(w+10,35, 0xff888888, 0xff222222);
5380 W but_2 =
margin(but_1,0,0,0,0);
5382 W lay_2 =
layer(but_3,txt_1);
5384 W mrg =
margin(contents, 5,5+30,5,5);
5385 W lay_1 =
layer(mrg,lay_2);
5388 W left =
button(5,h+5,0xff888888,0xff222222);
5389 W right =
button(5,h+5,0xff888888,0xff222222);
5390 W l_margin =
margin(left,0,30,0,0);
5391 W r_margin =
margin(right,w-4,30,0,0);
5393 W bottom =
button(w+10, 5, 0xff888888,0xff222222);
5394 W b_margin =
margin(bottom, 0, h+5+30, 0,0);
5396 W lay_3 =
layer(l_margin, r_margin);
5397 W lay_4 =
layer(lay_3,b_margin);
5398 W lay_6 =
layer(lay_4,lay_1);
5416 W bm_1 =
lines(p, sh, w,h, screen_size_x,screen_size_y);
5417 W bm_2 =
margin(bm_1, 10,10,10,10);
5419 W bm_4 =
layer(bm_3, bm_2);
5421 W but_1 =
text(
"Close", atlas, atlas_bm);
5426 W but_5 =
layer(but_41, but_3);
5428 close_button = but_6;
5430 W code_1 =
text(
"CodeGen", atlas, atlas_bm);
5435 W code_5 =
layer(code_41, code_3);
5437 codegen_button = code_6;
5440 std::vector<W> arr = { bm_4, code_6, but_6 };
5459 W bm_1 =
pts(p, sh, w,h, screen_size_x,screen_size_y);
5460 W bm_2 =
margin(bm_1, 10,10,10,10);
5462 W bm_4 =
layer(bm_3, bm_2);
5464 W but_1 =
text(
"Close", atlas, atlas_bm);
5469 W but_5 =
layer(but_41, but_3);
5471 close_button = but_6;
5473 W code_1 =
text(
"CodeGen", atlas, atlas_bm);
5478 W code_5 =
layer(code_41, code_3);
5480 codegen_button = code_6;
5483 std::vector<W> arr = { bm_4, code_6, but_6 };
5502void user_fptr(
void *user_data,
float mouse_x,
float mouse_y,
int button,
int ch,
int type,
int mouse_wheel_y)
5504 UserData *dt = (UserData*)user_data;
5508 float xx = mouse_x-pos.
x;
5509 float yy = mouse_y-pos.
y;
5514 int ssx = b2->
SizeX();
5515 int ssy = b2->
SizeY();
5518 std::stringstream ss;
5519 if (xx<0 ||xx>=ssx || yy<0 ||yy>=ssy)
5522 ss <<
" X:" << int(xx) <<
" Y:" << int(yy);
5530 if (ev.bitmap_api.ready_to_prepare(bm))
5531 ev.bitmap_api.prepare(bm);
5532 float sx = float(ev.bitmap_api.size_x(bm));
5533 float sy = float(ev.bitmap_api.size_y(bm));
5535 float change = 400.0/sx;
5539 float change = 400.0/sy;
5544 CBM cbm = ev.cont_bitmap_api.from_bitmap(bm, 1.0,1.0);
5545 BM cbm_2 = ev.cont_bitmap_api.sample(cbm,
int(sx),
int(sy));
5547 W bm_1 =
icon(cbm_2);
5548 W bm_2 =
margin(bm_1, 10,10,10,10);
5550 W bm_4 =
layer(bm_3, bm_2);
5552 std::stringstream ss;
5553 ss <<
"SX:" << ev.bitmap_api.size_x(bm) <<
" SY:" << ev.bitmap_api.size_y(bm);
5555 UserData *dt =
new UserData;
5563 W sztext =
text(ss.str(), atlas_tiny, atlas_tiny_bm);
5564 W mousepoint =
dynamic_text(
"0123456789/XY: ", &dt->s, user_fptr, (
void*)dt, atlas_tiny, atlas_tiny_bm, 3);
5565 W arr5[] = { sztext, mousepoint};
5566 W arr_52 =
array_x(&arr5[0], 2, 0);
5568 W but_1 =
text(
"Close", atlas, atlas_bm);
5573 W but_5 =
layer(but_41, but_3);
5575 close_button = but_6;
5577 W code_1 =
text(
"CodeGen", atlas, atlas_bm);
5582 W code_5 =
layer(code_41, code_3);
5584 codegen_button = code_6;
5586 std::vector<W> arr = { bm_4, arr_52, code_6, but_6 };
5593EXPORT GameApi::W GameApi::GuiApi::edit_dialog(
EveryApi &ev,
const std::vector<std::string> &labels,
const std::vector<GameApi::GuiApi::EditTypes*> &vec,
FtA atlas,
BM atlas_bm,
const std::vector<std::string> &types,
W &cancel_but,
W &ok_but,
FtA atlas_tiny,
BM atlas_tiny_bm, std::vector<W> &vec3)
5595 assert(vec.size()==labels.size());
5596 assert(labels.size()==types.size());
5597 std::vector<W> vec2;
5598 std::vector<W> vec2_ed;
5599 std::vector<W> vec2_lab;
5604 for(
int j=0;j<s;j++)
5606 std::string label = labels[j];
5607 W lab =
text(label, atlas,atlas_bm, 8);
5609 if (size_x1 < s) size_x1 = s;
5614 int max_width_lab=0;
5615 for(
int i=0;i<s;i++)
5619 std::string type = types[i];
5620 std::string label = labels[i];
5621 W lab =
text(label, atlas,atlas_bm, 8);
5623 W edit =
generic_editor(ev,*target, atlas, atlas_bm, type, 2, atlas_tiny, atlas_tiny_bm,
size_y(lab),vec3[i]);
5625 max_width_lab=std::max(max_width_lab,
size_x(lab));
5627 W array2[] = { lab_2, edit };
5628 W array3 =
array_x(&array2[0], 2, 5);
5630 vec2.push_back(array3);
5631 vec2_ed.push_back(edit);
5632 vec2_lab.push_back(lab_2);
5634 int extra_margin = 50;
5635 int button_width = std::max(
max_width/2+30+extra_margin*2/2,350);
5636 bool is_empty =
false;
5640 W lab0 =
text(
"", atlas, atlas_bm, 8);
5641 W lab =
text(
"(No data)", atlas, atlas_bm, 8);
5643 vec2.push_back(lab0);
5644 vec2.push_back(lab_2);
5645 vec2.push_back(lab0);
5649 W array =
array_y(vec2 , is_empty?35:35-30-15);
5650 for(
int i=0;i<s;i++)
5656 W array_0 =
array_y(vec2 ,is_empty?35:35-30-15);
5657 W array_1 =
margin(array_0, 10,10,10,10);
5660 W array_3 =
layer(array_2, array_1a);
5664 W cancel_button_1 =
text(
"Cancel", atlas,atlas_bm, 4);
5665 W cancel_button_11 =
center_align(cancel_button_1, button_width);
5666 W cancel_button_111 =
center_y(cancel_button_11, 50);
5667 W cancel_button_2 =
layer(cancel_button, cancel_button_111);
5669 W cancel_button_4 =
layer(cancel_button_2, cancel_button_3);
5670 W cancel_area =
click_area(cancel_button_4, 0,0,button_width,50,0);
5671 cancel_but = cancel_area;
5673 W ok_button_1 =
text(
"Ok", atlas,atlas_bm, 4);
5675 W ok_button_111 =
center_y(ok_button_11, 50);
5676 W ok_button_2 =
layer(ok_button, ok_button_111);
5678 W ok_button_4 =
layer(ok_button_2, ok_button_3);
5679 W ok_area =
click_area(ok_button_4, 0,0,button_width,50,0);
5681 W button_array[] = { cancel_area, ok_area };
5682 W button_arr =
array_x(&button_array[0], 2, 0);
5683 std::vector<W> combine_array = { array_3, button_arr };
5684 W combine_arr =
array_y(combine_array , 0);
5686 return combine_move;
5694 Point2d p = { -666.0, -666.0 };
5698 void set_pos(Point2d pos)
5701 Vector2d
size = vec[0]->get_size();
5702 Point2d p = { pos.
x + sx -
size.dx, pos.
y };
5705 void update(Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
5710 size.dy = vec[0]->get_size().dy;
5715class LeftAlignWidget :
public GuiWidgetForward
5718 LeftAlignWidget(GameApi::EveryApi &
ev, GuiWidget *wid,
int sx) : GuiWidgetForward(
ev, { wid }), sx(sx) {
5719 Point2d p = { -666.0, -666.0 };
5723 void set_pos(Point2d pos)
5727 Point2d p = { pos.
x, pos.
y };
5730 void update(Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
5735 size.dy = vec[0]->get_size().dy;
5740class CenterAlignWidget :
public GuiWidgetForward
5743 CenterAlignWidget(GameApi::EveryApi &
ev, GuiWidget *wid,
int sx) : GuiWidgetForward(
ev, { wid }), sx(sx) {
5744 Point2d p = { -666.0, -666.0 };
5748 void set_pos(Point2d pos)
5751 Vector2d
size = vec[0]->get_size();
5752 Point2d p = { pos.
x + (sx -
size.dx)/2, pos.
y };
5755 void update(Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
5760 size.dy = vec[0]->get_size().dy;
5766class CenterYWidget :
public GuiWidgetForward
5769 CenterYWidget(GameApi::EveryApi &
ev, GuiWidget *wid,
int sy) : GuiWidgetForward(
ev, { wid }), sy(sy) {
5770 Point2d p = { -666.0, -666.0 };
5774 void set_pos(Point2d pos)
5777 Vector2d
size = vec[0]->get_size();
5778 Point2d p = { pos.
x, pos.
y + (sy-
size.dy)/2};
5781 void update(Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
5785 size.dx = vec[0]->get_size().dx;
5796 return add_widget(e,
new RightAlignWidget(ev, wid, sx));
5801 return add_widget(e,
new LeftAlignWidget(ev, wid, sx));
5806 return add_widget(e,
new CenterAlignWidget(ev, wid, sx));
5811 return add_widget(e,
new CenterYWidget(ev, wid, sy));
5815bool is_enum(std::string type)
5817 if (type.size()>2 && type[0]==
'{' && type[type.size()-1]==
'}')
5831 if (type==
"EveryApi&")
5836 std::stringstream ss(source);
5837 if (ss >> target.l_value) {
5838 target.expr =
"@" + expr;
5840 }
else { std::cout <<
"StringStream failed" << std::endl; }
5843 if (type==
"int"||is_enum(type))
5845 std::stringstream ss(source);
5846 target.expr =
"@" + expr;
5847 if (ss >> target.i_value) {
5849 }
else { std::cout <<
"StringStream failed" << std::endl; }
5852 if (type==
"unsigned int")
5854 target.color =
"@" + source;
5855 target.expr =
"@" + expr;
5857 if (type==
"std::string")
5860 target.expr =
"@" + expr;
5865 std::stringstream ss(source);
5866 ss >> target.f_value;
5867 target.expr =
"@" + expr;
5871 target.expr =
"@" + expr;
5872 target.s =
"@" + source;
5876 std::stringstream ss(source);
5887 std::cout <<
"Unknown type at string_to_generic" << std::endl;
5895 if (type==
"EveryApi&")
5903 std::stringstream ss;
5906 if (source.
expr.size()>0 && source.
expr[0]==
'@')
5907 expr = source.
expr.substr(1,source.
expr.size()-1);
5912 if (type==
"int"||is_enum(type))
5916 std::stringstream ss;
5919 if (source.
expr.size()>0 && source.
expr[0]==
'@')
5920 expr = source.
expr.substr(1,source.
expr.size()-1);
5925 if (type==
"unsigned int")
5927 std::string s = source.
color.size()>0 && source.
color[0]==
'@' ? source.
color.substr(1,source.
color.size()-1) : source.
color;
5929 if (source.
expr.size()>0 && source.
expr[0]==
'@')
5930 expr = source.
expr.substr(1,source.
expr.size()-1);
5934 if (type==
"std::string")
5936 std::string s = source.
s;
5938 if (source.
expr.size()>0 && source.
expr[0]==
'@')
5939 expr = source.
expr.substr(1,source.
expr.size()-1);
5945 std::string s = source.
s;
5946 if (source.
expr.size()>0 && source.
expr[0]==
'@')
5947 expr = source.
expr.substr(1,source.
expr.size()-1);
5950 if (s.size()>0 && s[0]==
'@')
5951 target = s.substr(1,s.size()-1);
5958 std::stringstream ss;
5961 if (source.
expr.size()>0 && source.
expr[0]==
'@')
5962 expr = source.
expr.substr(1,source.
expr.size()-1);
5968 float x = source.
f_x;
5969 float y = source.
f_y;
5970 float z = source.
f_z;
5971 std::stringstream ss;
5972 ss <<
"(" << x <<
"," << y <<
"," << z <<
")";
5977 std::cout <<
"Unknown type at generic_to_string: " << type << std::endl;
5984 if (type==
"EveryApi&")
5991 W edit =
long_editor(target.l_value, atlas, atlas_bm, x_gap,1, target.expr);
5997 W edit =
enum_editor(ev,click_target, target.i_value, atlas, atlas_bm, x_gap, type,target.expr,1);
6003 W edit =
int_editor(target.i_value, target.expr, atlas, atlas_bm, x_gap,1);
6006 if (type==
"unsigned int")
6008 W edit =
color_editor(target.color, atlas, atlas_bm, x_gap,1,target.expr);
6011 if (type==
"std::string" || type==
"bool")
6013 if (target.s.size()>4 && (target.s.substr(0,4)==
"http" ||target.s.substr(0,4)==
"file"))
6016 W edit =
url_editor(target.s, atlas_tiny, atlas_tiny_bm, x_gap,target.expr,1);
6023 std::string allowed =
"0123456789abcdefghijklmnopqrstuvwxyz/.ABCDEFGHIJKLMNOPQRSTUVWXYZ*()-#+/*!\"€%&?\n,:_@";
6024 static W redraw_w =
empty();
6025 W edit =
string_editor(allowed, target.s, target.expr, atlas, atlas_bm, x_gap,1,&redraw_w);
6030 std::string allowed =
"0123456789abcdefghijklmnopqrstuvwxyz\xE5\xE4\xF6/.ABCDEFGHIJKLMNOPQRSTUVWXYZ\xC5\xC4\xD6*()-#+/*!\"€%&?\n,:_@ |?;[]{}";
6031 static W redraw_w =
empty();
6032 W edit =
string_editor(allowed, target.s, target.expr, atlas_tiny, atlas_tiny_bm, x_gap,1,&redraw_w);
6040 W edit =
float_editor(target.f_value, target.expr, atlas, atlas_bm, x_gap,1);
6045 W edit =
point_editor(target.f_x, target.f_y, target.f_z, atlas, atlas_bm, x_gap);
6048 std::cout <<
"TYPE ERROR: " << type << std::endl;
6056 static std::string expr;
6057 W l0 =
text(
"(",atlas, atlas_bm);
6060 W l1 =
text(
";",atlas, atlas_bm);
6063 W l2 =
text(
";",atlas,atlas_bm);
6066 W l3 =
text(
")",atlas,atlas_bm);
6067 W array[] = { l0, x_edit_2, l1, y_edit_2, l2, z_edit_2, l3 };
6068 return array_x(&array[0], 7, 2);
6073 return add_widget(e,
new HighlightGuiWidget(ev, sh, sx,sy));
6078 return add_widget(e,
new Highlight2GuiWidget(ev, w, sh));
6083 return add_widget(e,
new LayoutGuiWidget(ev, ww, l, t,
W,
H,r, b));
6085EXPORT GameApi::W GameApi::GuiApi::layout_lt(
W w,
int l,
int t,
int W,
int H,
int r,
int b,
int (*fptr_l)(
void *),
int (*fptr_t)(
void *),
void *ctx,
void *ctx2)
6088 return add_widget(e,
new LayoutGuiWidget(LayoutGuiWidget_lt(), ev, ww, l, t,
W,
H,r, b,fptr_l,fptr_t,ctx,ctx2));
6090EXPORT GameApi::W GameApi::GuiApi::layout_wh(
W w,
int l,
int t,
int W,
int H,
int r,
int b,
int (*fptr_W)(
void *),
int (*fptr_H)(
void *),
void *ctx,
void *ctx2)
6093 return add_widget(e,
new LayoutGuiWidget(LayoutGuiWidget_WH(), ev, ww, l, t,
W,
H,r, b,fptr_W,fptr_H,ctx,ctx2));
6095EXPORT GameApi::W GameApi::GuiApi::layout_rb(
W w,
int l,
int t,
int W,
int H,
int r,
int b,
int (*fptr_r)(
void *),
int (*fptr_b)(
void *),
void *ctx,
void *ctx2)
6098 return add_widget(e,
new LayoutGuiWidget(LayoutGuiWidget_rb(), ev, ww, l, t,
W,
H,r, b,fptr_r,fptr_b,ctx,ctx2));
6101int fptr_empty(
void *) {
return 0; }
6102struct Empty2 {
int W; };
6103int fptr_empty2(
void *ctx) { Empty2 *
e = (Empty2*)ctx;
return e->W; }
6104EXPORT GameApi::W GameApi::GuiApi::layout_lh(
W w,
int l,
int t,
int W,
int H,
int r,
int b,
int (*fptr_l)(
void*),
int (*fptr_H)(
void*),
void *ctx,
void *ctx2)
6108 GameApi::W w0 =
layout_lt(w,l,0,
W,
ELayoutEmpty,r,0,fptr_l, fptr_empty, ctx, 0);
6109 GameApi::W w1 =
layout_wh(w0,0,t,
ELayoutEmpty,
H,0,b, fptr_empty2, fptr_H, (
void*)&e,ctx2);
6116 return add_widget(e,
new MarginGuiWidget(ev, ww, l, t, r, b));
6121 return add_widget(e,
new SizeGuiWidget(ev, ww, sx,sy));
6127 return add_widget(e,
new LayerGuiWidget(ev, ww1, ww2));
6132 std::vector<GuiWidget*> vec;
6133 for(
int i=0;i<s;i++)
6137 return add_widget(e,
new ArrayXWidget(ev, vec, x_gap));
6142 std::vector<GuiWidget*> vec;
6143 for(
int i=0;i<s;i++)
6147 return add_widget(e,
new ArrayYWidget(ev, vec, y_gap,heavy));
6152 int s = labels.size();
6154 for(
int i=0;i<s;i++)
6156 std::string s = labels[i];
6157 W txt_1 =
text(s, atlas, atlas_bm);
6158 W txt_2 =
margin(txt_1, 5,5,5,5);
6160 W txt_4 =
layer(txt_2, txt_3);
6161 vec.push_back(txt_4);
6163 W w =
array_x(&vec[0], vec.size(), 20);
6180 float clamp(
float val,
float start,
float end)
6182 if (val<start) val=start;
6183 if (val>end) val=end;
6186 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
6188 Point2d p = get_pos();
6189 float size_y = float(sy)/float(area_y)*float(sy-2-2-2-2);
6190 float pos_y = current_pos * (float(sy) - clamp(
float(sy)/
float(area_y),0.0,1.0)*float(sy-2-2-2-2));
6191 if (button==0 && type == 1025 && !following && mouse.
x>=p.
x+2+2 && mouse.
x<p.
x+sx-2-2 && mouse.
y>=p.
y+pos_y+2+2 && mouse.
y<p.
y+pos_y+2+2+size_y)
6196 if (button==0 && following)
6198 float delta = mouse.
y - start_pos.y;
6199 current_pos = current_pos + delta/float(sy-2-2-2-2);
6201 if (current_pos < 0.0) current_pos = 0.0;
6202 if (current_pos > 1.0) current_pos = 1.0;
6211 if (firsttime || changed)
6215 GameApi::BB b =
ev.bool_bitmap_api.bb_empty(sx,sy);
6216 GameApi::BB b1 =
ev.bool_bitmap_api.rectangle(b, 0.0, 0.0,
float(sx), 2.0);
6217 GameApi::BB b2 =
ev.bool_bitmap_api.rectangle(b1, 0.0, 0.0, 2.0,
float(sy));
6218 GameApi::BB b3 =
ev.bool_bitmap_api.rectangle(b2,
float(sx)-2.0, 0.0, 2.0,
float(sy));
6219 GameApi::BB b4 =
ev.bool_bitmap_api.rectangle(b3, 0.0,
float(sy)-2.0,
float(sx), 2.0);
6220 bg =
ev.bool_bitmap_api.to_bitmap(b4, 255,255,255,255, 0,0,0,0);
6222 bg_va =
ev.sprite_api.create_vertex_array(bg);
6223 GameApi::BB k =
ev.bool_bitmap_api.bb_empty(sx-2-2-2-2, clamp(
float(sy)/
float(area_y),0.0,1.0)*
float(sy-2-2-2-2));
6224 GameApi::BB k2 =
ev.bool_bitmap_api.rectangle(k, 0.0, 0.0,
float(sx-2-2-2-2), clamp(
float(sy)/
float(area_y),0.0,1.0)*
float(sy-2-2-2-2));
6225 thumb =
ev.bool_bitmap_api.to_bitmap(k2, 255,255,255,255, 0,0,0,0);
6226 thumb_va =
ev.sprite_api.create_vertex_array(thumb);
6231 old_area_y = area_y;
6240 Point2d p = get_pos();
6241 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x, p.
y, 0.0));
6242 ev.sprite_api.render_sprite_vertex_array(bg_va);
6244 float pos_y = current_pos * (float(sy) - clamp(
float(sy)/
float(area_y),0.0,1.0)*float(sy));
6245 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x+2+2+0.5, p.
y+pos_y+2+2+0.5, 0.0));
6246 ev.sprite_api.render_sprite_vertex_array(thumb_va);
6250 float dynamic_param(
int id)
const
6252 if (
id==0) {
return current_pos; }
6255 void set_dynamic_param(
int id,
float val)
6259 if (area_y!=old_area_y)
6270 GameApi::VA thumb_va;
6278 bool button_pressed;
6281class ScrollBarX :
public GuiWidgetForward
6284 ScrollBarX(GameApi::EveryApi &
ev, GameApi::SH sh,
int sx,
int sy,
int area_x) : GuiWidgetForward(
ev, std::vector<GuiWidget*>()), sh(sh), sx(sx), sy(sy), area_x(area_x) { firsttime=
true; current_pos = 0.0; following =
false; changed=
false; old_area_x = area_x; }
6285 void update(Point2d mouse,
int button,
int ch,
int type,
int mouse_wheel_y)
6287 Point2d p = get_pos();
6288 float size_x = float(sx)/float(area_x)*float(sx-2-2-2-2);
6289 float pos_x = current_pos * (float(sx) - float(sx)/float(area_x)*float(sx-2-2-2-2));
6290 if (button==0 && type==1025 && !following && mouse.
y>=p.
y+2+2 && mouse.
y<p.
y+sy-2-2 && mouse.
x>=p.
x+pos_x+2+2 && mouse.
x<p.
x+pos_x+2+2+size_x)
6295 if (button==0 && following)
6297 float delta = mouse.
x - start_pos.x;
6298 current_pos = current_pos + delta/float(sx-2-2-2-2);
6300 if (current_pos < 0.0) current_pos = 0.0;
6301 if (current_pos > 1.0) current_pos = 1.0;
6310 if (firsttime ||changed)
6314 GameApi::BB b =
ev.bool_bitmap_api.bb_empty(sx,sy);
6315 GameApi::BB b1 =
ev.bool_bitmap_api.rectangle(b, 0.0, 0.0,
float(sx), 2.0);
6316 GameApi::BB b2 =
ev.bool_bitmap_api.rectangle(b1, 0.0, 0.0, 2.0,
float(sy));
6317 GameApi::BB b3 =
ev.bool_bitmap_api.rectangle(b2,
float(sx)-2.0, 0.0, 2.0,
float(sy));
6318 GameApi::BB b4 =
ev.bool_bitmap_api.rectangle(b3, 0.0,
float(sy)-2.0,
float(sx), 2.0);
6319 bg =
ev.bool_bitmap_api.to_bitmap(b4, 255,255,255,255, 0,0,0,0);
6321 bg_va =
ev.sprite_api.create_vertex_array(bg);
6322 GameApi::BB k =
ev.bool_bitmap_api.bb_empty(
float(sx)/
float(area_x)*
float(sx-2-2-2-2), sy-2-2-2-2);
6323 GameApi::BB k2 =
ev.bool_bitmap_api.rectangle(k, 0.0, 0.0,
float(sx)/
float(area_x)*
float(sx-2-2-2-2),
float(sy-2-2-2-2));
6324 thumb =
ev.bool_bitmap_api.to_bitmap(k2, 255,255,255,255, 0,0,0,0);
6325 thumb_va =
ev.sprite_api.create_vertex_array(thumb);
6330 old_area_x = area_x;
6339 Point2d p = get_pos();
6340 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x, p.
y, 0.0));
6341 ev.sprite_api.render_sprite_vertex_array(bg_va);
6343 float pos_x = current_pos * (float(sx) - float(sx)/float(area_x)*float(sx));
6344 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(p.
x+pos_x+2+2+0.5, p.
y+2+2+0.5, 0.0));
6345 ev.sprite_api.render_sprite_vertex_array(thumb_va);
6349 float dynamic_param(
int id)
const
6351 if (
id==0) {
return current_pos; }
6354 void set_dynamic_param(
int id,
float val)
6358 if (old_area_x != area_x)
6369 GameApi::VA thumb_va;
6379float wave_transfer(
float val,
float start_range, std::function<
float(
float)>
f,
float time)
6382 float v =
f(val+time);
6385class WaveformWidget :
public GuiWidget
6388 WaveformWidget(GameApi::EveryApi &
ev, GameApi::SH sh, std::function<
float (
float)>
f,
float start_range,
float end_range,
float min_value,
float max_value,
int sx,
int sy,
unsigned int true_color,
unsigned int false_color) :
ev(
ev), sh(sh),
f(
f), start_range(start_range), end_range(end_range), min_value(min_value), max_value(max_value), sx(sx), sy(sy), true_color(true_color), false_color(false_color)
6391 Point2d p = { -666.0, -666.0 };
6393 Point2d p2 = { 0.0, 0.0 };
6397 bool is_visible()
const {
return true; }
6398 Point2d get_pos()
const {
return pos; }
6399 Vector2d get_size()
const {
return size; }
6400 void set_pos(Point2d pos_p) { pos = pos_p; }
6401 void set_size(Vector2d vec_p) {
size = vec_p; }
6402 void update(Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
6406 GameApi::WV wave =
ev.waveform_api.function(std::bind(&wave_transfer, GameApi::_1, start_range,
f, std::ref(time)), end_range-start_range, min_value, max_value);
6407 wave_bm =
ev.waveform_api.waveform_bitmap(wave, sx, sy, true_color, false_color);
6408 wave_bm_va =
ev.sprite_api.create_vertex_array(wave_bm);
6412 ev.sprite_api.update_vertex_array(wave_bm_va, wave_bm);
6414 Vector2d s = { float(sx), float(sy) };
6423 Point2d pos = get_pos();
6424 ev.shader_api.set_var(sh,
"in_MV",
ev.matrix_api.trans(pos.
x+0.5, pos.
y+0.5, 0.0));
6425 ev.sprite_api.render_sprite_vertex_array(wave_bm_va);
6433 void select_item(
int item) { }
6434 int chosen_item()
const {
return -1; }
6435 float dynamic_param(
int id)
const {
return 0.0; }
6436 void set_dynamic_param(
int id,
float val) { }
6438 GuiWidget *child(
int num)
const {
return 0; }
6439 bool content_changed()
const {
return true; }
6440 void clear_content_changed() { }
6443 GameApi::BM wave_bm;
6444 GameApi::VA wave_bm_va;
6447 GameApi::EveryApi &
ev;
6449 std::function<float (
float)>
f;
6450 float start_range, end_range;
6451 float min_value, max_value;
6453 unsigned int true_color, false_color;
6463 ScrollAreaWidget(
GameApi::EveryApi &
ev,
GameApi::SH sh,
GuiWidget *orig,
int sx,
int sy,
int screen_y,
bool disable_wheel) :
GuiWidgetForward(
ev, { orig }), sh(sh), orig(orig), sx(sx), sy(sy), screen_y(screen_y), disable_wheel(disable_wheel) { firsttime =
true;
Vector2d v = { float(sx),float(sy)};
size = v; top=0.0; left=0.0;
6464 mouse_wheel_move=0.0;
6471 vec[0]->set_pos(pos2);
6480 void update(
Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
6483 static bool is_inside=
false;
6484 if (mouse.
x>=pos.
x-80 && mouse.
x<pos.
x+
size.dx+80 &&
6485 mouse.
y>=pos.
y-80 && mouse.
y<pos.
y+
size.dy+80)
6490 orig->
update(mouse, button,ch, type, mouse_wheel_y);
6497 Point2d mouse = {-666.0, -666.0 };
6498 orig->
update(mouse, button,ch, type, mouse_wheel_y);
6502 if (!disable_wheel && type==1027 && mouse.
x>pos.
x && mouse.
x<pos.
x+
size.dx &&
6503 mouse.
y>pos.
y && mouse.
y<pos.
y+
size.dy)
6506 mouse_wheel_move+=mouse_wheel_y*80.0;
6510 vec[0]->set_pos(pos2);
6542 int chosen_item()
const {
return orig->
chosen_item(); }
6543 void set_dynamic_param(
int id,
float val)
6546 case 0: left = val;
break;
6547 case 1: top = val;
break;
6553 vec[0]->set_pos(pos2);
6563 float mouse_wheel_move;
6567class OrElemGuiWidget :
public GuiWidget
6570 OrElemGuiWidget(GameApi::Env &
env, GameApi::W (*fptr1)(
void*), GameApi::W (*fptr2)(
void*),
void*
data)
6576 virtual bool is_visible()
const {
return isVisible; }
6577virtual Point2d get_pos()
const { check();
if (b)
return w1->get_pos();
else return w2->get_pos(); }
6578virtual Vector2d get_size()
const { check();
if (b)
return w1->get_size();
else return w2->get_size(); }
6579virtual void set_pos(Point2d pos) { check();
if (b) w1->set_pos(pos);
else w2->set_pos(pos); }
6580virtual void set_size(Vector2d
size) { check();
if (b) w1->set_size(
size);
else w2->set_size(
size); }
6581virtual void update(Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y) { check();
if (b) w1->update(mouse_pos, button,ch,type,mouse_wheel_y);
else w2->update(mouse_pos, button,ch,type,mouse_wheel_y); }
6582virtual void render() {
if (is_visible()) { check();
if (b) w1->render();
else w2->render();} }
6583virtual int render_to_bitmap() { check();
if (b)
return w1->render_to_bitmap();
else return w2->render_to_bitmap(); }
6584 virtual void select_item(
int item) { check();
if (item==0) b=
true;
if (item==1) b=
false;
update(Point2d(-666.0,-666.0), -1,-1,-1,0); set_size(get_size()); }
6585virtual int chosen_item()
const { check();
if (b)
return w1->chosen_item();
else return w2->chosen_item(); }
6586virtual float dynamic_param(
int id)
const { check();
if (b)
return w1->dynamic_param(
id);
else return w2->dynamic_param(
id); }
6587virtual void set_dynamic_param(
int id,
float val) { check();
if (b) w1->set_dynamic_param(
id, val);
else w2->set_dynamic_param(
id, val); }
6588virtual int child_count()
const { check();
if (b) {
return w1->child_count(); }
else {
return w2->child_count(); } }
6589virtual bool content_changed()
const { check();
if (b) {
return w1->content_changed(); }
else {
return w2->content_changed(); } }
6590virtual void clear_content_changed() { check();
if (b) { w1->clear_content_changed(); }
else { w2->clear_content_changed(); } }
6591 virtual GuiWidget *child(
int num)
const
6593 if (b) {
return w1->child(
num); }
6594 else {
return w2->child(
num); }
6600 GameApi::W w = fptr1(
data);
6606 GameApi::W w = fptr2(
data);
6614 mutable GuiWidget *w1=0;
6615 mutable GuiWidget *w2=0;
6616 GameApi::W (*fptr1)(
void*);
6617 GameApi::W (*fptr2)(
void*);
6624 BM bm = ev.bitmap_api.gradient_y(
color_1, color_2, sx, sy);
6629struct ButtonCacheItem
6634 unsigned int color_2;
6637std::vector<ButtonCacheItem*> button_cache;
6638ButtonCacheItem* find_from_button_cache(
int sx,
int sy,
unsigned int color_1,
unsigned int color_2)
6640 int s = button_cache.size();
6641 for(
int i=0;i<s;i++)
6643 ButtonCacheItem *item = button_cache[i];
6644 if (sx==item->sx && sy==item->sy &&
color_1 == item->color_1 && color_2==item->color_2)
return item;
6654 ButtonCacheItem *item = find_from_button_cache(sx,sy,
color_1,color_2);
6661 PT pt1 = ev.point_api.point(0.0, 0.0, 0.0);
6662 PT pt2 = ev.point_api.point(0.0, sy, 0.0);
6663 BM w = ev.bitmap_api.gradient_y(
color_1, color_2, sx,sy);
6664 unsigned int color_1L =
color_1;
6665 unsigned int color_2L = color_2;
6667 unsigned char *ptr = (
unsigned char *)&color_1L;
6668 unsigned char *ptr2 = (
unsigned char *)&color_2L;
6669 ptr[0] = (
unsigned char) (
float(ptr[0])*0.8);
6670 ptr[1] = (
unsigned char) (
float(ptr[1])*0.8);
6671 ptr[2] = (
unsigned char) (
float(ptr[2])*0.8);
6672 ptr[3] = (
unsigned char) (
float(ptr[3])*0.8);
6673 ptr2[0] = (
unsigned char) (
float(ptr2[0])*0.8);
6674 ptr2[1] = (
unsigned char) (
float(ptr2[1])*0.8);
6675 ptr2[2] = (
unsigned char) (
float(ptr2[2])*0.8);
6676 ptr2[3] = (
unsigned char) (
float(ptr2[3])*0.8);
6678 BM w2 = ev.bitmap_api.gradient_y( color_1L, color_2L,sx,sy);
6680 unsigned int color_1D =
color_1;
6681 unsigned int color_2D = color_2;
6683 unsigned char *ptrD = (
unsigned char*)&color_1D;
6684 unsigned char *ptr2D = (
unsigned char*)&color_2D;
6685 ptrD[0] = (
unsigned char) (
float(ptrD[0])*0.6);
6686 ptrD[1] = (
unsigned char) (
float(ptrD[1])*0.6);
6687 ptrD[2] = (
unsigned char) (
float(ptrD[2])*0.6);
6688 ptrD[3] = (
unsigned char) (
float(ptrD[3])*0.6);
6689 ptr2D[0] = (
unsigned char) (
float(ptr2D[0])*0.6);
6690 ptr2D[1] = (
unsigned char) (
float(ptr2D[1])*0.6);
6691 ptr2D[2] = (
unsigned char) (
float(ptr2D[2])*0.6);
6692 ptr2D[3] = (
unsigned char) (
float(ptr2D[3])*0.6);
6694 BM w3 = ev.bitmap_api.gradient_y( color_1D, color_2D,sx,sy);
6696 BB mask_0 = ev.bool_bitmap_api.bb_empty(sx,sy);
6697 BB mask_0a = ev.bool_bitmap_api.rectangle(mask_0, 0.0, 0.0,
float(sx), 2.0);
6698 BB mask_0b = ev.bool_bitmap_api.rectangle(mask_0a, 0.0, 0.0, 2.0,
float(sy));
6699 BB mask_1 = mask_0b;
6701 BB mask__0 = ev.bool_bitmap_api.bb_empty(sx,sy);
6702 BB mask__0a = ev.bool_bitmap_api.rectangle(mask__0,
float(sx-2), 0.0, 2.0, sy);
6703 BB mask__0b = ev.bool_bitmap_api.rectangle(mask__0a, 0.0,
float(sy-2),
float(sx), 2.0);
6704 BB mask_2 = mask__0b;
6706 BM w4 = ev.bitmap_api.blitbitmap_bb(w2, w, 0, 0, mask_1);
6707 BM w5 = ev.bitmap_api.blitbitmap_bb(w4, w3, 0, 0, mask_2);
6710 ButtonCacheItem *item2 =
new ButtonCacheItem;
6714 item2->color_2 = color_2;
6716 button_cache.push_back(item2);
6724 int key = sx+sy+
color_1+color_2;
6731 return add_widget(e,
new OrElemGuiWidget(e,w1_func,w2_func,
data));
6735 return add_widget(e,
new ScrollBarY(ev,sh, sx,sy,area_y));
6739 return add_widget(e,
new ScrollBarX(ev,sh, sx,sy,area_x));
6744 return add_widget(e,
new ScrollAreaWidget(ev, sh, orig_1, sx,sy, screen_y,
false));
6749 return add_widget(e,
new ScrollAreaWidget(ev, sh, orig_1, sx,sy, screen_y,
true));
6752EXPORT GameApi::W GameApi::GuiApi::canvas_scroll_area(
int sx,
int sy,
int screen_x,
int screen_y)
6758 return add_widget(e,
new WaveformWidget(ev, sh,
f, start_range, end_range, min_value, max_value, sx, sy, true_color, false_color));
6763 int s = w->child(0)->child(1)->child_count();
6764 if (menu_id<0 || menu_id>=s) { std::cout <<
"ERROR: Wrong menu id" << menu_id <<
" " << s << std::endl;
exit(0); }
6769 int ss = labels.size();
6771 for(
int i=0;i<ss;i++) {
6772 std::string s = labels[i];
6773 W txt_1 =
text(s, atlas, atlas_bm);
6774 W txt_2 =
margin(txt_1, 2,2,2,2);
6776 W txt_4 =
layer(txt_2, txt_3);
6777 vec.push_back(txt_4);
6792 int ss = labels.size();
6794 for(
int i=0;i<ss;i++) {
6795 std::string s = labels[i];
6796 W txt_1 =
text(s, atlas, atlas_bm);
6797 W txt_2 =
margin(txt_1, 2,2,2,2);
6799 W txt_4 =
layer(txt_2, txt_3);
6801 std::stringstream ss;
6803 std::string
id = ss.str();
6805 vec.push_back(txt_5);
6806 areas.push_back(txt_5);
6821 for(
int i=0;i<s;i++)
6824 int bm_id = w->render_to_bitmap();
6830 GameApi::BB bb3 =
ev.bool_bitmap_api.from_float_bitmap(fb, 0.1, 1.2);
6831 bg =
ev.bitmap_api.blitbitmap_bb(bg, bm_id_1, (
int)p.
x, (
int)p.
y, bb3);
6889 if (!ww) {
return -1; }
6901 if (!ww) {
return 0.0; }
6912 return ww2->
vec.size();
6927 int s =
env->widgets.size();
6928 for(
int i=0;i<s;i++)
6979int to_int(std::string s);
6986 GameApiEditNode_float_coord(
int count, std::string param_type, std::string param_value, std::string param_name) : source(0), mode(0), count(count), param_type(param_type), param_value(param_value), param_name(param_name) { move=
false; mod=
false; source=0; mode=0; }
6987 void SetSource(
int i) { source=i; }
6988 void SetMode(
int i) { mode=i; }
6989 void CurrentPos(Point &p)
const
6991 if (param_type==
"float") {
6992 std::stringstream ss(param_value);
6993 if (mode==1) { ss >> p.
x; }
6994 if (mode==2) { ss >> p.
y; }
6995 if (mode==3) { ss >> p.
z; }
6998 void HandleMouseMove(
int x,
int y)
7001 if (source==1) { res = x; mod =
true;}
7002 if (source==2) { res = y; mod =
true; }
7003 if (mod && move && param_type==
"float") {
7004 std::stringstream ss;
7006 param_value = ss.str();
7012 void HandleMousePress(
int type) {
7013 if (type==1) { move=
true; }
7014 if (type==2) { move=
false; }
7016 std::string GetValue()
const {
return param_value; }
7021 std::string param_type;
7022 std::string param_value;
7023 std::string param_name;
7033 if (mode==0) {
count=0; }
7034 if (mode==1) {
count++; }
7039std::vector<GameApi::EditNode*> collectnodes(std::string
name, std::vector<std::string> param_type, std::vector<std::string> param_names, std::vector<std::string> params, std::vector<std::string> param_name)
7041 int s=param_type.size();
7042 std::cout <<
"Params: " << s << std::endl;
7043 for(
int i=0;i<s;i++)
7046 std::cout <<
count <<
" " <<
name <<
":" << param_type[i] <<
" " << param_names[i] <<
": " << param_name[i] << std::endl;
7048 return std::vector<GameApi::EditNode*>();
7053int template_get_id(T t) {
return t.
id; }
7054int template_get_id(GameApi::ARR a) {
return 0; }
7056void funccall_1(std::vector<std::string> &s, GameApi::ExecuteEnv &
e, std::vector<std::string> param_name);
7060int find_char(
const std::string &line,
int start_char,
char ch,
bool braces=
true)
7062 int s = line.size();
7064 for(
int i=start_char;i<s;i++)
7066 if (braces && (line[i]==
'(' ||line[i]==
'{')) { level++; }
7068 if (line[i]==ch && level==0)
return i;
7069 if (braces && ((line[i]==
')' ||line[i]==
'}') && level>0)) { level--; }
7073int find_one(std::string line,
int start_char, std::string
chars,
bool braces=
true)
7075 int s = line.size();
7077 for(
int i=start_char;i<s;i++)
7079 if (braces && (line[i]==
'('||line[i]==
'{')) { level++; }
7080 int ss =
chars.size();
7082 for(
int j=0;j<ss;j++)
7084 if (line[i]==
chars[j])
7091 if (braces && ((line[i]==
')'||line[i]==
'}') && level>0)) { level--; }
7092 if (found) {
return i; }
7096int extend_until(std::string line,
int start_char, std::string
chars)
7098 int s = line.size();
7099 for(
int i=start_char;i<s;i++)
7101 int ss =
chars.size();
7103 for(
int j=0;j<ss;j++)
7104 if (line[i]==
chars[j]) { b=
true; }
7112 std::string return_type;
7113 std::string label_num;
7115 std::string func_name;
7116 std::vector<std::string> params;
7117 std::vector<std::string> param_names;
7118 std::vector<std::string> params_linkage;
7123void CodeGenLineErrorCheck(CodeGenLine &line, std::vector<GameApiItem*>
functions)
7127 for(
int i=0;i<s;i++)
7130 if (item->
ApiName(0) == line.api_name && item->
FuncName(0)==line.func_name)
7133 if (item->
ParamCount(0) !=
int(line.params.size()))
7137 int s = item->
ParamCount(0) - line.params.size();
7138 int old_size = line.params.size();
7140 for(
int j=0;j<s;j++) {
7141 line.params.push_back(item->
ParamDefault(0,old_size + j));
7145 std::cout << item->
ParamCount(0)<<
"!=" << line.params.size() <<
" -- " << item->
ApiName(0) <<
"::" << item->
FuncName(0) <<
"(";
7147 for(
int ii=0;ii<ss;ii++)
7150 if (ii!=ss-1) std::cout <<
" ";
7152 std::cout <<
");" << std::endl;
7153 int ss2 = line.params.size();
7154 std::cout << line.api_name <<
"::" << line.func_name <<
"(";
7155 for(
int j=0;j<ss2;j++)
7157 std::cout << line.params[j];
7158 if (j!=ss2-1) std::cout <<
" ";
7160 std::cout <<
");" << std::endl;
7166 std::cout <<
"ERROR: function not found! " << std::endl;
7167 int ss2 = line.params.size();
7168 std::cout << line.api_name <<
"::" << line.func_name <<
"(";
7169 for(
int j=0;j<ss2;j++)
7171 std::cout << line.params[j];
7172 if (j!=ss2-1) std::cout <<
" ";
7174 std::cout <<
");" << std::endl;
7178std::ostream &
operator<<(std::ostream &o,
const std::vector<T> &v)
7181 for(
int i=0;i<s;i++)
7184 if (i!=s-1) { o <<
","; }
7195 for(
int i=0;i<s;i++)
7197 if (
api_name == lst[i]->ApiName(0) && func_name==lst[i]->FuncName(0))
7200 return lst[i]->ParamName(0,ii);
7203 std::cout <<
"find_param_name failed for" <<
api_name <<
" " << func_name << std::endl;
7208CodeGenLine parse_codegen_line(GameApi::EveryApi &
ev, std::string line)
7212 CodeGenLine
error = {
"@",
"@",
"@",
"@", { } };
7213 int first_space =
find_char(line, 0,
' ');
7214 if (first_space==-1) { std::cout <<
"parse_codegen_line: first space error: " << std::endl;
return error; }
7215 std::string return_type = line.substr(0,first_space);
7216 if (line[first_space+1]!=
'I') { std::cout <<
"parse_codegen_line: I error:" << std::endl;
return error; }
7217 int num_end_iterator = extend_until(line, first_space+2,
"0123456789");
7218 if (num_end_iterator==-1) { std::cout <<
"parse_codegen_line: 012345689:" << std::endl;
return error; }
7219 std::string
num = line.substr(first_space+2, num_end_iterator-first_space-2);
7220 if (line[num_end_iterator]!=
'=') { std::cout <<
"parse_codegen_line: '=' error:" << std::endl;
return error; }
7221 if (line[num_end_iterator+1]!=
'e') { std::cout <<
"parse_codegen_line: 'e' error:" << std::endl;
return error; }
7222 if (line[num_end_iterator+2]!=
'v') { std::cout <<
"parse_codegen_line: 'v' error:" << std::endl;
return error; }
7223 if (line[num_end_iterator+3]!=
'.') { std::cout <<
"parse_codegen_line: '.' error:" << std::endl;
return error; }
7225 if (end==-1) { std::cout <<
"parse_codegen_line2: '.' error:" << std::endl;
return error; }
7226 std::string
api_name = line.substr(num_end_iterator+4, end-num_end_iterator-4);
7227 int end2 =
find_char(line,end+1,
'(',
false);
7228 if (end2==-1) { std::cout <<
"parse_codegen_line2: '(' error:" << std::endl;
return error; }
7229 std::string func_name = line.substr(end+1, end2-end-1);
7230 std::vector<std::string> params;
7231 std::vector<std::string> param_names;
7234 int end3 = find_one(line, end2+1,
"),");
7235 if (end3==-1) { std::cout <<
"parse_codegen_line2: '),' error:" << std::endl;
return error; }
7236 if (end3==end2+1 && line[end3]==
')') {
break; }
7237 std::string p = line.substr(end2+1,end3-end2-1);
7238 if (p.size()>0 && p[0]==
'"' && p[p.size()-1]==
'"')
7240 p=p.substr(1,p.size()-2);
7242 params.push_back(p);
7245 if (line[end3]==
')') {
break; }
7250 if (line[end2]!=
')') end2++;
7251 if (line[end2]==
')' &&
7252 line[end2+1]==
';' &&
7253 line[end2+2]==
' ' &&
7254 line[end2+3]==
'/' &&
7255 line[end2+4]==
'/' &&
7258 int end4 = find_one(line,end2+6,
",\n\0");
7260 std::string sx = line.substr(end2+6,end4-end2-6);
7261 std::string sy = line.substr(end4+1,line.size()-end4-1);
7262 std::stringstream ssx(sx);
7264 std::stringstream ssy(sy);
7270 line2.return_type = return_type;
7271 line2.label_num =
"I" +
num;
7273 line2.func_name = func_name;
7274 line2.params = params;
7275 line2.param_names = param_names;
7282int find_str(std::string val, std::string repl);
7284GameApiParam convert_param(GameApi::EveryApi &
ev,
const std::vector<CodeGenLine> &lines,
const std::vector<GameApiLine> &lines2, std::string
api_name, std::string func_name,
int i, std::string param,
int j)
7289 int s = funcs.size();
7290 std::string param_name;
7291 for(
int ii=0;ii<s;ii++)
7293 GameApiItem *item = funcs[ii];
7300 if (param_name==
"") std::cout <<
"Warning: " <<
api_name <<
"::" << func_name <<
" param " << i <<
" name not found." << std::endl;
7302 int s2 = lines.size();
7303 const CodeGenLine *res_line=0;
7304 const GameApiLine *res_line2=0;
7305 for(
int i2=0;i2<s2;i2++)
7307 const CodeGenLine &line = lines[i2];
7308 if (param==line.label_num)
7310 res_line = &lines[i2];
7311 res_line2 = &lines2[i2];
7318 res.
value = res_line?res_line2->
uid:param;
7322 if (p0!=-1 && p1!=-1)
7324 std::string label = param.substr(0,p0);
7325 std::string index = param.substr(p0+1,p1-p0-1);
7328 std::stringstream ss(index);
7330 std::string res_param=
"";
7332 int s2 = lines.size();
7333 const CodeGenLine *res_line=0;
7334 const GameApiLine *res_line2=0;
7335 for(
int i2=0;i2<s2;i2++)
7337 const CodeGenLine &line = lines[i2];
7338 if (label==line.label_num)
7340 res_line = &lines[i2];
7341 res_line2 = &lines2[i2];
7342 res_param = res_line2->
uid;
7346 res.
value = res_param;
7351 int pos =
find_str(param,
"std::vector<");
7352 int posA =
find_str(param,
"std::vector<");
7353 if (pos!=-1 || posA!=-1)
7356 if (posA!=-1) delta=16;
7358 int pos0b =
find_str(param,
">");
7359 if (pos0==-1) pos0=pos0b;
7360 std::string type = param.substr(pos+delta,pos0-pos-delta);
7363 std::string res_param =
"[";
7367 std::string arr_params = param.substr(pos1+1,(pos2-1)-pos1);
7369 std::string rest = arr_params;
7374 std::string param = rest.substr(0,pp);
7377 int s2 = lines.size();
7378 const CodeGenLine *res_line=0;
7379 const GameApiLine *res_line2=0;
7380 for(
int i2=0;i2<s2;i2++)
7382 const CodeGenLine &line = lines[i2];
7383 if (param==line.label_num)
7385 res_line = &lines[i2];
7386 res_line2 = &lines2[i2];
7387 res_param += res_line2->
uid +
",";
7390 rest = rest.substr(pp+1);
7392 std::string param = rest;
7394 int s2 = lines.size();
7395 const CodeGenLine *res_line=0;
7396 const GameApiLine *res_line2=0;
7397 for(
int i2=0;i2<s2;i2++)
7399 const CodeGenLine &line = lines[i2];
7400 if (param==line.label_num)
7402 res_line = &lines[i2];
7403 res_line2 = &lines2[i2];
7404 res_param += res_line2->
uid;
7409 res.
value = res_param;
7414 res.
is_array = res_line && res_line->return_type.size()>0 && res_line->return_type[0]==
'[' && res_line->return_type[res_line->return_type.size()-1]==
']' ? true :
false;
7420struct CodeGenVectors {
7421 std::vector<std::string> params;
7426GameApiLine convert_line(GameApi::EveryApi &
ev, std::vector<CodeGenLine> &lines, std::vector<GameApiLine> &lines2,
const std::vector<CodeGenVectors> &vecs, CodeGenLine l,
int i)
7428 static int uid = 3333;
7431 std::stringstream ss; ss <<
"uid" << uid;
7433 int pos = lines2.size();
7434 int pos_x = pos % 6;
7435 int pos_y = pos / 6;
7440 float start_x = 200.0;
7441 float start_y = 200.0;
7448 int s2 = funcs.size();
7449 std::string module_name =
"";
7450 GameApiItem *res_item = 0;
7451 for(
int k=0;k<s2;k++)
7453 GameApiItem *item = funcs[k];
7456 module_name = item->
Name(0);
7464 res.
x = l.x != -1 ? l.x : start_x + pos_x*
delta_x;
7465 res.
y = l.y != -1 ? l.y : start_y + pos_y*
delta_y;
7468 res.
j = i<vecs.size()&&vecs[i].j.size()>0?vecs[i].j[0]:0;
7469 res.
sz = i<vecs.size()?vecs[i].j.size():1;
7470 res.
array_return = l.return_type.size()>0 && l.return_type[0]==
'[' && l.return_type[l.return_type.size()-1]==
']';
7472 int s = std::max(
int(l.params.size()),res_item->
ParamCount(0));
7473 for(
int i=0;i<s;i++)
7475 if (i>=l.params.size())
7479 res.
params.push_back(convert_param(
ev,lines,lines2,l.api_name,l.func_name,i,param,j));
7482 std::string param = l.params[i];
7486 res.
params.push_back(convert_param(
ev,lines,lines2,l.api_name,l.func_name,i,param,j));
7492std::vector<GameApiLine>
convert_script(GameApi::EveryApi &
ev, std::string script);
7494GameApiFunction convert_lines_to_functions(std::vector<GameApiLine> lines)
7496 GameApiFunction res;
7503GameApiModule convert_function_to_module(GameApiFunction
f)
7510void save_gameapi(
const GameApiModule &mod, std::string filename);
7512void save_mod_txt_from_script_file(GameApi::EveryApi &
ev, std::string input_script_filename, std::string output_mod_txt_filename)
7514 std::ifstream input(input_script_filename);
7515 std::stringstream buffer;
7516 buffer << input.rdbuf();
7517 std::string script = buffer.str();
7519 GameApiFunction
f = convert_lines_to_functions(lines);
7520 GameApiModule m = convert_function_to_module(
f);
7521 save_gameapi(m,output_mod_txt_filename);
7524GameApiModule load_gameapi(GameApi::EveryApi &
ev, std::string filename);
7526bool line_match(
const GameApiLine &l1,
const GameApiLine &l2)
7530 int s1 = l1.
params.size();
7531 int s2 = l2.
params.size();
7535 for(
int k=0;k<s1;k++)
7537 if (l1.
params[k].value.size()>3 && l1.
params[k].value[0]==
'u' && l1.
params[k].value[1]==
'i' && l1.
params[k].value[2]==
'd')
7539 if (l1.
params[k].value != l2.
params[k].value) match=
false;
7541 if (l2.
params[k].value.size()>3 && l2.
params[k].value[0]==
'u' && l2.
params[k].value[1]==
'i' && l2.
params[k].value[2]==
'd')
7543 if (l1.
params[k].value != l2.
params[k].value) match=
false;
7553void transfer_x_y_from_old_mod_txt_to_new_one(GameApi::EveryApi &
ev,
7554 std::string old_mod_filename,
7557 GameApiModule mod0 = load_gameapi(
ev,old_mod_filename);
7558 GameApiFunction &f0 = mod0.
funcs[0];
7559 GameApiFunction &f1 = mod.
funcs[0];
7560 int s = f1.
lines.size();
7562 for(
int i=0;i<s;i++)
7564 GameApiLine &l1 = f1.
lines[i];
7565 GameApiLine &l2 = f0.
lines[cursor];
7566 bool match = line_match(l1,l2);
7577 if (cursor+diff<f0.
lines.size()) {
7578 GameApiLine &l2d = f0.
lines[cursor+diff];
7579 bool match1 = line_match(l1,l2d);
7589 if (i+diff<f1.
lines.size()) {
7590 GameApiLine &l1d = f1.
lines[i+diff];
7591 bool match2 = line_match(l1d,l2);
7601 if (!
done)
continue;
7613 std::ifstream input(input_script_filename);
7614 std::stringstream buffer;
7615 buffer << input.rdbuf();
7616 std::string script = buffer.str();
7620 save_gameapi(m,output_mod_txt_filename);
7622 std::ifstream input(input_script_filename);
7623 std::stringstream buffer;
7624 buffer << input.rdbuf();
7625 std::string script = buffer.str();
7630 transfer_x_y_from_old_mod_txt_to_new_one(
ev,
7631 output_mod_txt_filename,
7633 save_gameapi(m,output_mod_txt_filename);
7643void onerror_cb(
unsigned int tmp,
void *
arg,
int,
const char*)
7645 std::cout <<
"ERROR: onerror_cb" << std::endl;
7647 std::string url_str(
url);
7652 std::cout <<
"async_pending_count dec (onerror_cb) -->" <<
async_pending_count << std::endl;
7656void onprogress_cb(
unsigned int tmp,
void *,
int,
int) { }
7657void onload_cb(
unsigned int tmp,
void *
arg,
void *
data,
unsigned int datasize)
7659 std::vector<unsigned char> buffer;
7660 unsigned char *dataptr = (
unsigned char*)
data;
7662 for(
int i=0;i<dt;i++) { buffer.push_back(dataptr[i]); }
7665 std::string url_str(
url);
7671 std::cout <<
"async_pending_count dec (onlosd_cb) -->" <<
async_pending_count << std::endl;
7674 int s = url_plain.size();
7676 for(
int i=0;i<s;i++) sum+=
int(url_plain[i]);
7684ASyncData async_data[] = {
7685 {
"font_api",
"newfont", 0 },
7686 {
"font_api",
"load_font", 0 },
7687 {
"mainloop_api",
"load_song", 2 },
7689 {
"polygon_api",
"p_url", 1 },
7691 {
"polygon_api",
"p_url_mtl", 1 },
7693 {
"polygon_api",
"p_mtl", 1 },
7695 {
"polygon_api",
"p_mtl", 2 },
7697 {
"polygon_api",
"p_mtl2", 1 },
7699 {
"polygon_api",
"p_mtl2", 2 },
7700 {
"mainloop_api",
"fps_display", 2 },
7701 {
"mainloop_api",
"score_display", 2 },
7702 {
"mainloop_api",
"time_display", 2 },
7711 {
"polygon_api",
"p_ds_url", 1 },
7712 {
"bitmap_api",
"intbitmap_loader", 0 },
7713 {
"mainloop_api",
"restart_screen", 2 },
7714 {
"tracker_api",
"play_wave_via_keypress", 2 },
7715 {
"mainloop_api",
"playback_keypresses", 1 },
7716 {
"bitmap_api",
"world_from_bitmap3", 2 },
7718 {
"mainloop_api",
"state_int_fetcher", 0 },
7719 {
"mainloop_api",
"state_speed_movement", 1 },
7721 {
"low_frame_api",
"low_sprite_array", 1 },
7722 {
"low_frame_api",
"low_build_world", 1 },
7723 {
"low_frame_api",
"low_enemy_draw", 1 },
7724 {
"low_frame_api",
"low_enemy_draw2", 1 },
7725 {
"polygon_api",
"stl_load", 0 },
7726 {
"font_api",
"load_font_dump", 0 },
7727 {
"polygon_api",
"load_scene", 1 },
7733 {
"polygon_api",
"bar_chart", 1 },
7734 {
"polygon_api",
"bar_chart2", 1 },
7735 {
"polygon_api",
"piechart_full", 4 },
7744 {
"mainloop_api",
"matrix_range_check", 3 },
7745 {
"font_api",
"draw_text_large", 2 },
7746 {
"bitmap_api",
"loadbitmapfromurl", 0},
7747 {
"mainloop_api",
"parse_areatype", 1},
7748 {
"mainloop_api",
"create_landscape", 1},
7749 {
"mainloop_api",
"bind_obj_type", 1},
7750 {
"mainloop_api",
"read_obj_pos", 0},
7751 {
"polygon_api",
"mesh_anim", 6},
7752 {
"materials_api",
"many_texture_id_material", 1},
7753 {
"bitmap_api",
"script_bitmap", 0},
7754 {
"points_api",
"ply_pts", 0 },
7755 {
"points_api",
"ply_faces", 0 },
7756 {
"mainloop_api",
"memmap_window2", 1 },
7757 {
"mainloop_api",
"memmap_window3", 1 },
7758 {
"mainloop_api",
"memmap_window3", 2 },
7759 {
"mainloop_api",
"memmap_window3", 3 },
7760 {
"mainloop_api",
"memmap_window3", 4 },
7761 {
"mainloop_api",
"memmap_window3", 5 },
7762 {
"mainloop_api",
"memmap_window3", 6 },
7763 {
"polygon_api",
"ske_anim", 4 },
7764 {
"polygon_api",
"ske_anim2", 4 },
7765 {
"lines_api",
"li_url", 0 },
7770 {
"mainloop_api",
"async_url", 0},
7773 {
"mainloop_api",
"tunnel_tree", 3},
7775 {
"materials_api",
"gltf_material_from_file", 1},
7776 {
"mainloop_api",
"gltf_loadKK", 1},
7777 {
"mainloop_api",
"gltf_loadKK2", 0},
7778 {
"mainloop_api",
"html_url", 0 },
7779 {
"mainloop_api",
"gltf_load_sketchfab_zip", 0 },
7780 {
"mainloop_api",
"game", 3 },
7781 {
"mainloop_api",
"game", 4 },
7782 {
"mainloop_api",
"game", 5 },
7783 {
"mainloop_api",
"game", 6 },
7784 {
"matrices_api",
"render_ms_files", 3 },
7785 {
"matrices_api",
"render_ms_files2", 3 },
7786 {
"voxel_api",
"voxel_from_bitmaps", 1 },
7787 {
"points_api",
"load_points", 0 },
7788 {
"bitmap_api",
"debug_number", 4},
7789 {
"bitmap_api",
"video_source", 0},
7790 {
"mainloop_api",
"load_ML_script3",1},
7791 {
"voxel_api",
"vox_voxel", 1},
7792 {
"voxel_api",
"vox_voxel2", 1},
7793 {
"voxel_api",
"vox_voxel3", 1},
7794 {
"voxel_api",
"vox_cubes", 1},
7795 {
"voxel_api",
"vox_ml", 1},
7796 {
"voxel_api",
"vox_bind_ml",1},
7797 {
"voxel_api",
"vox_ml2", 1},
7798 {
"voxel_api",
"vox_bind_ml2",1},
7799 {
"voxel_api",
"lod_vox", 1},
7800 {
"texture_api",
"videofile_txid_generic", 3},
7801 {
"mainloop_api",
"AI_modified", 2},
7802 {
"mainloop_api",
"AI_generated", 2}
7806IMPORT ASyncData *g_async_ptr = &async_data[0];
7807IMPORT int g_async_count =
sizeof(async_data)/
sizeof(ASyncData);
7812ASyncData async_data2[] = {
7813 {
"polygon_api",
"p_mtl", 1 },
7814 {
"polygon_api",
"p_mtl2", 1 },
7815 {
"polygon_api",
"p_url", 1 }
7822std::vector<std::string> g_async_loaded_urls;
7823bool is_async_loaded_urls_in_vec(std::string
url)
7825 int s= g_async_loaded_urls.size();
7826 for(
int i=0;i<s;i++) {
7827 if (g_async_loaded_urls[i]==
url)
return true;
7831struct ASyncCallback { void (*fptr)(
void*);
void *
data; };
7837 void del_url(std::string
url)
7852 std::map<std::string, std::vector<unsigned char>* > load_url_buffers_async;
7865void async_cb(
void *
data)
7870std::vector<ASyncCallback*> g_async_vec;
7871std::vector<std::string> g_async_vec2;
7875 int s = g_async_vec.size();
7876 for(
int i=0;i<s;i++) {
7878 std::string
url = g_async_vec2[i];
7880 if (cb &&
g_del_map.async_find(std::string(
"load_url.php?url=") +
url) &&
g_del_map.async_get2(std::string(
"load_url.php?url=") +
url) != 0) {
7891std::vector<std::string> g_extra_async_urls;
7893bool is_in_vec(std::string
url)
7895 int s = g_extra_async_urls.size();
7896 for(
int i=0;i<s;i++) {
if (g_extra_async_urls[i]==
url)
return true; }
7906class RegisterUrl :
public MainLoopItem
7909 RegisterUrl(std::string
url, MainLoopItem *next) : next(next) {
7912 void Collect(CollectVisitor &vis) { next->
Collect(vis); }
7913 void HeavyPrepare() { }
7914 virtual void Prepare() { next->
Prepare(); }
7915 virtual void execute(MainLoopEnv &
e) { next->
execute(
e); }
7916 virtual void handle_event(MainLoopEvent &
e) { next->
handle_event(
e); }
7917 virtual std::vector<int> shader_id() {
return next->
shader_id(); }
7938void LoadUrls_async(
GameApi::Env &
e,
const CodeGenLine &line, std::string homepage)
7945 int s = line.param_names.size();
7946 for(
int ii=0;ii<s;ii++)
7953 std::string
url = line.params[param_num];
7957 if (!is_async_loaded_urls_in_vec(
url)) {
7960 e.async_load_url(
url,homepage);
7962 g_async_loaded_urls.push_back(
url);
7967 g_async_vec.push_back(cb);
7968 g_async_vec2.push_back(
url);
7976void LoadUrls(
const CodeGenLine &line, std::string homepage)
7984 std::string
url = line.params[0];
7985 std::cout <<
"loading url: " <<
url << std::endl;
7990 for(
int i=0;i<s;i++) sum+=
int(
url[i]);
7995 std::string url2 =
"load_url.php";
7996 std::string urlend =
"url=" +
url +
"&homepage=" + homepage;
7997 url =
"load_url.php?url=" +
url +
"&homepage=" + homepage;
7999 char *buf2 =
new char[url2.size()+1];
8000 std::copy(url2.begin(), url2.end(), buf2);
8001 buf2[url2.size()]=0;
8003 char *buf3 =
new char[
url.size()+1];
8004 std::copy(
url.begin(),
url.end(), buf3);
8008 std::cout <<
"async_pending_count inc (LoadUrls) -->" <<
async_pending_count << std::endl;
8010 LoadData *ld =
new LoadData;
8015 emscripten_idb_async_exists(
"gameapi", oldurl.c_str(), (
void*)ld, &idb_exists2, &idb_error2);
8017 emscripten_async_wget2_data(buf2,
"POST", urlend.c_str(), (
void*)buf3, 1, &onload_cb, &onerror_cb, &onprogress_cb);
8023void LoadUrls_codegen(GameApi::Env &
env, std::vector<CodeGenLine> vec, std::string homepage)
8025 int s2 = vec.size();
8026 for(
int i=0;i<s2;i++) {
8027 CodeGenLine l = vec[i];
8032 for(
int i=0;i<s;i++) {
8033 CodeGenLine l = vec[i];
8034 LoadUrls(l, homepage);
8035 LoadUrls_async(
env,l, homepage);
8043 std::vector<std::string> param_names;
8046struct FunctionCallSpec
8048 bool is_function_call;
8049 std::string return_type;
8050 std::string label_num;
8051 std::string func_name;
8052 std::vector<std::string> params;
8055FunctionCallSpec is_funccall(
int lineno, std::string line)
8057 FunctionCallSpec spec;
8058 spec.is_function_call =
false;
8059 int first_space =
find_char(line,0,
' ');
8060 if (first_space==-1) {
return spec; }
8061 std::string return_type = line.substr(0,first_space);
8062 if (line[first_space+1]!=
'I') {
return spec; }
8063 int num_end_iterator = extend_until(line,first_space+2,
"0123456789");
8064 if (num_end_iterator==-1) {
return spec; }
8065 std::string
num = line.substr(first_space+2,num_end_iterator-first_space-2);
8066 if (line[num_end_iterator]!=
'=') {
return spec; }
8067 if (line[num_end_iterator+1]==
'e' && line[num_end_iterator+2]==
'v' && line[num_end_iterator+3]==
'.') {
return spec; }
8068 int brace_pos =
find_char(line,num_end_iterator+1,
'(');
8069 if (brace_pos==-1)
return spec;
8070 std::string func_name = line.substr(num_end_iterator+1,brace_pos-num_end_iterator-1);
8071 int pos = brace_pos+1;
8072 int close_brace_pos =
find_char(line,pos,
')');
8073 int comma_pos =
find_char(line,pos,
',');
8074 std::vector<std::string> params;
8075 while(close_brace_pos!=-1 && comma_pos!=-1) {
8076 int next_pos = comma_pos!=-1 ? comma_pos : close_brace_pos;
8077 std::string param = line.substr(pos,next_pos-pos);
8078 params.push_back(param);
8081 close_brace_pos =
find_char(line,pos,
')');
8084 spec.is_function_call=
true;
8085 spec.func_name = func_name;
8086 spec.params = params;
8091FunctionSpec is_line_function(
int lineno, std::string line)
8093 std::stringstream ss;
8096 int pos = extend_until(line,0,
" \t");
8098 std::string
str = line.substr(pos,8);
8099 if (
str!=
"function") { FunctionSpec spec; spec.is_function=
false;
return spec; }
8100 }
else { FunctionSpec spec; spec.is_function=
false;
return spec; }
8101 int pos2 = find_one(line,pos,
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
false);
8102 if (pos2==-1) { FunctionSpec spec; spec.is_function=
false;
return spec; }
8103 name = line.substr(pos,pos2-pos);
8104 std::cout <<
"Function name:" <<
name << std::endl;
8106 if (ch!=
'(') { FunctionSpec spec; spec.is_function=
false;
return spec; }
8107 std::vector<std::string> param_names;
8111 pos3 = extend_until(line,pos2+1,
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
8112 if (pos3==-1)
break;
8113 std::string param_name = line.substr(pos2+1,pos3-pos2-1);
8114 param_names.push_back(param_name);
8115 if (line[pos3]==
')')
break;
8116 if (line[pos3]!=
',') { std::cout <<
"Line: " << lineno <<
" parse error at '" << line[pos3] <<
"'!" << std::endl; FunctionSpec spec; spec.is_function=
false;
return spec; }
8119 int pos4 = extend_until(line,pos3+1,
" \t");
8121 char ch2 = line[pos4];
8122 if (ch2 !=
'{') { std::cout <<
"Line: " << lineno <<
" parse error at '" << ch2 <<
"'!" << std::endl; FunctionSpec spec; spec.is_function=
false;
return spec; }
8126 spec.is_function =
true;
8128 spec.param_names = param_names;
8131bool is_line_function_end(std::string line)
8133 int pos = extend_until(line,0,
" \t");
8141 std::vector<std::string> param_names;
8142 std::vector<CodeGenLine> impl;
8146std::vector<CodeGenLine> parse_codegen(GameApi::Env &
env, GameApi::EveryApi &
ev, std::string text,
int &error_line_num, std::vector<FunctionImpl4> &
functions)
8152 std::vector<std::vector<CodeGenLine> > linestack;
8153 std::vector<FunctionImpl4> stack;
8154 std::vector<CodeGenLine> vec;
8158 std::string homepage =
ev.mainloop_api.get_homepage_url();
8159 while((idx=
find_char(text, idx,
'\n'))!= -1)
8161 std::string line = text.substr(old_idx, idx-old_idx-1);
8164 FunctionSpec s = is_line_function(line_num,line);
8165 if (s.is_function) {
8168 impl.param_names = s.param_names;
8169 stack.push_back(impl);
8170 linestack.push_back(vec);
8173 bool sb = is_line_function_end(line);
8174 if (sb && stack.size()==0) { std::cout <<
"ERROR: function nesting problem!" << std::endl; error_line_num = line_num;
return vec; }
8175 if (sb && stack.size()>0)
8177 FunctionImpl4 impl = stack[stack.size()-1];
8180 vec = linestack[linestack.size()-1];
8181 linestack.pop_back();
8184 FunctionCallSpec
call = is_funccall(line_num,line);
8185 if (
call.is_function_call)
8188 line2.return_type =
call.return_type;
8189 line2.label_num =
call.label_num;
8190 line2.api_name =
"@";
8191 line2.func_name =
call.func_name;
8192 line2.params =
call.params;
8193 vec.push_back(line2);
8200 if (line.size()<10) {
8206 CodeGenLine l = parse_codegen_line(
ev,line);
8207 CodeGenLineErrorCheck(l, funcs);
8208 if (l.return_type==
"@") {
8209 std::cout <<
"ERROR:" << line << std::endl;
8210 error_line_num = line_num;
return vec; }
8216 if (line_num > 1800) {
8218 std::cout <<
"Number of lines in CodeGen is limited to 1800 lines" << std::endl;
8229std::pair<std::string, int> parse_multiple_return(std::string param)
8231 int s = param.size();
8234 for(
int i=0;i<s;i++) {
8235 if (param[i]==
'[') {
8238 if (param[i]==
']') {
8242 if (start==s || end==s)
return std::make_pair(param,0);
8243 std::string res = param.substr(0,start);
8244 std::string index = param.substr(start+1,end-start-1);
8245 std::stringstream ss(index);
8249 return std::make_pair(res,ii);
8252void add_params_linkage(std::vector<CodeGenLine> &lines, std::vector<CodeGenVectors> &vectors,
bool &
error, std::map<std::string, int> env_map)
8256 std::map<std::string, int> line_map;
8257 int s = lines.size();
8258 for(
int i=0;i<s;i++)
8260 CodeGenLine l = lines[i];
8261 line_map[l.label_num] = i;
8266 int s2 = lines.size();
8267 for(
int i=0;i<s2;i++)
8269 CodeGenLine l = lines[i];
8270 int ss = l.params.size();
8271 for(
int j=0;j<ss;j++)
8273 std::string param_value = l.params[j];
8274 std::string param_linkage =
"";
8276 std::pair<std::string,int> pp = parse_multiple_return(param_value);
8278 if (pp.first.size()>0 && pp.first[0]==
'I' && line_map.find(pp.first)!=line_map.end())
8280 int linkage = line_map[pp.first];
8283 std::stringstream ss;
8285 param_linkage = ss.str();
8287 }
else if (pp.first[0]==
'I') {
8288 std::cout <<
"Param not found (multiple return+find failed)" << pp.first << std::endl;
8289 std::cout << l.return_type <<
" " << l.api_name <<
"::" << l.func_name << std::endl;
8291 if (param_value.size()>strlen(
"std::vector<"))
8294 std::string substr = param_value.substr(0,strlen(
"std::vector<"));
8295 if (substr==
"std::vector<")
8298 int pos =
find_char(param_value, 13,
'>');
8299 if (pos==-1) {
error =
true;
return; }
8300 std::string type = param_value.substr(13,pos);
8301 if (param_value[pos+1]!=
'{') {
error=
true;
return; }
8305 int pos2 = find_one(param_value, pos,
",}");
8306 if (pos2==pos+1)
break;
8307 if (pos2==-1) { std::cout <<
"Error=true" << std::endl; std::cout << l.return_type <<
" " << l.api_name <<
"::" << l.func_name << std::endl;
error=
true;
return; }
8308 std::string param = param_value.substr(pos,pos2-pos);
8311 std::pair<std::string,int> pp2 = parse_multiple_return(param);
8313 std::string param_linkage =
"";
8314 if (pp2.first.size()>0 && pp2.first[0]==
'I')
8316 int linkage = line_map[pp2.first];
8317 std::map<std::string,int>::iterator ii2 = line_map.find(pp2.first);
8318 if (ii2==line_map.end()) {
8319 std::map<std::string,int>::iterator ii=line_map.begin();
8320 for(;ii!=line_map.end();ii++) { std::pair<std::string,int> p=*ii; std::cout <<
"LINE MAP CONTAINS: (" << p.first <<
" " << p.second <<
")" << std::endl; }
8321 std::cout <<
"ERROR: Param not found! (multiple return)'" << pp2.first <<
"'"<< std::endl; std::cout << l.return_type <<
" " << l.api_name <<
"::" << l.func_name << std::endl; }
8323 std::stringstream ss;
8325 param_linkage = ss.str();
8326 }
else if (pp2.first.size()>0 && pp2.first[0]==
'E')
8328 int linkage = env_map[pp2.first];
8329 if (!linkage) { std::cout <<
"ERROR: E not found! " << pp2.first << std::endl; std::cout << l.return_type <<
" " << l.api_name <<
"::" << l.func_name << std::endl; }
8331 std::stringstream ss;
8333 param_linkage = std::string(
"E") + ss.str();
8335 param_linkage = param;
8337 vec.params.push_back(param_linkage);
8338 vec.j.push_back(pp.second);
8340 if (param_value[pos2]==
'}')
break;
8342 vectors.push_back(vec);
8344 std::stringstream ss;
8345 ss << vectors.size()-1;
8346 param_linkage = std::string(
"%") + ss.str();
8350 lines[i].params_linkage.push_back(param_linkage);
8351 lines[i].j.push_back(jj);
8357std::vector<GameApiLine>
convert_script(GameApi::EveryApi &
ev, std::string script)
8359 std::stringstream ss(script);
8361 std::vector<CodeGenLine> lines;
8362 std::vector<GameApiLine> lines2;
8363 while(std::getline(ss,line))
8365 CodeGenLine l = parse_codegen_line(
ev,line);
8368 std::vector<CodeGenVectors> vecs;
8370 std::map<std::string,int> env_map;
8371 add_params_linkage(lines,vecs,
error,env_map);
8372 if (
error) {
return std::vector<GameApiLine>(); }
8373 int s = lines.size();
8374 for(
int i=0;i<s;i++)
8376 GameApiLine l2 = convert_line(
ev,lines,lines2,vecs,lines[i], i);
8377 lines2.push_back(l2);
8383void link_api_items(std::vector<CodeGenLine> &vec, std::vector<GameApiItem*>
functions)
8386 for(
int i=0;i<s;i++)
8388 CodeGenLine &line = vec[i];
8391 for(
int j=0;j<ss;j++)
8396 if (line.func_name == item->
FuncName(0) &&
8397 line.api_name == item->
ApiName(0))
8403 if (found==
false) { std::cout <<
"NOT FOUND: " << line.api_name <<
" " << line.func_name<< std::endl; }
8408bool is_num(std::string s)
8411 for(
int i=0;i<ss;i++)
8413 if (s[i]<
'0' || s[i]>
'9')
return false;
8419bool has_envparams_markers(std::string s);
8421std::vector<int> execute_api(GameApi::Env &ee, GameApi::EveryApi &
ev,
const std::vector<CodeGenLine> &vec, std::vector<CodeGenVectors> &vecvec,
int , GameApi::ExecuteEnv &
e)
8423 std::vector<std::string> res_vec;
8424 int s2 = vec.size();
8426 for(
int ij=0;ij<s2;ij++)
8428 CodeGenLine l = vec[ij];
8430 int s = l.params_linkage.size();
8431 std::vector<std::string> params = l.params;
8432 for(
int i=0;i<s;i++)
8434 std::string
link = l.params_linkage[i];
8438 std::string sub =
link.substr(1);
8439 std::stringstream ss(sub);
8442 int val =
e.env[idx];
8443 std::stringstream ss2;
8445 params[i] = ss2.str();
8447 else if (
link.size()>0 &&
link[0]==
'%')
8450 std::string sub =
link.substr(1);
8451 std::stringstream ss(sub);
8454 int s = vecvec[idx].params.size();
8456 std::vector<std::string> params2;
8457 for(
int i=0;i<s;i++)
8459 std::string
link = vecvec[idx].params[i];
8460 int jj = vecvec[idx].j[i];
8462 std::stringstream ss(
link);
8467 std::string val = res_vec[
num];
8468 std::stringstream ss2(val);
8470 std::vector<std::string> vec;
8473 vec.push_back(val2);
8476 params2.push_back( vec[jj] );
8478 params2.push_back(
link);
8481 std::string res =
"[";
8482 for(
int i=0;i<s;i++)
8484 if (i!=0) { res+=
","; }
8485 std::string p = params2[i];
8493 std::stringstream ss(
link);
8499 std::string val =
num>=0&&
num<res_vec.size()?res_vec[
num]:
"";
8500 std::stringstream ss2(val);
8502 std::vector<std::string> vec;
8503 while(ss2>>val2) { vec.push_back(val2); }
8506 if (jj>=0 && jj<vec.size())
8507 params[i] = vec[jj];
8509 { params[i] =
""; std::cout <<
"ERROR: vec[jj] access outside bounds! (gameapi_gui.cc) jj=" << jj <<
" and i=" << i << std::endl;
8510 std::cout << l.api_name <<
"::" << l.func_name << std::endl;
8519 std::stringstream sk3;
8520 std::string ret_type = l.item->
ReturnType(0);
8523 int val = l.item->
Execute(sk3, ee,
ev, params,
e,-1);
8528 for(
int jj=0;jj<
count;jj++)
8530 int val2 = t->
vec[jj];
8531 std::stringstream ss2;
8535 if (jj!=count-1) res+=
" ";
8537 }
else { std::stringstream ss; ss << val; res=ss.str(); }
8538 res_vec.push_back(res);
8540 std::string s = res_vec[res_vec.size()-1];
8541 std::stringstream ss(s);
8543 std::vector<int> res_vec2;
8544 while(ss >> val) { res_vec2.push_back(val); }
8550std::string ToString(
int num)
8552 std::stringstream ss;
8560 int error_line_num = 0;
8561 std::vector<FunctionImpl4> funcs;
8562 std::vector<CodeGenLine> vec = parse_codegen(
env,
ev, text, error_line_num,funcs);
8563 if (vec.size()==0) {
8564 return std::make_pair(-1,std::string(
"Error at line ") + ToString(error_line_num));
8566 std::vector<CodeGenVectors> vecvec;
8567 std::map<std::string, int> envmap =
e.envmap;
8569 add_params_linkage(vec,vecvec,err2, envmap);
8570 if (err2) {
return std::make_pair(-1, std::string(
"Error at params_linkage")); }
8574 std::vector<int> val = execute_api(
env,
ev, vec, vecvec, vec.size()-1,
e);
8575 std::string homepage =
ev.mainloop_api.get_homepage_url();
8576 LoadUrls_codegen(
env,vec,homepage);
8577 CodeGenLine last = vec[vec.size()-1];
8578 if (last.return_type==
"BLK")
return std::make_pair(val[0],
"OK");
8579 return std::make_pair(val[0],last.return_type);
8601 GameApi::EveryApi &
ev;
8603 GameApi::ExecuteEnv &
e;
8605std::pair<std::string,std::string>
CodeGen_1(GameApi::EveryApi &
ev, std::vector<std::string> params, std::vector<std::string> param_names, std::vector<std::string> param_type, std::string return_type, std::string
api_name, std::string func_name,
int j);
8610#define CHAISCRIPT_NO_THREADS
8621std::vector<GameApiItem*> append_vectors(std::vector<GameApiItem*> vec1, std::vector<GameApiItem*> vec2);
8623std::vector<GameApiItem*> append_vectors(std::vector<GameApiItem*> vec1, std::vector<GameApiItem*> vec2)
8625 int s = vec2.size();
8626 for(
int i=0;i<s;i++)
8628 vec1.push_back(vec2[i]);
8663 std::vector<GameApiItem*> a1 = append_vectors(v1,v2);
8664 std::vector<GameApiItem*> a2 = append_vectors(v3,v4);
8665 std::vector<GameApiItem*> a3 = append_vectors(a1,a2);
8666 std::vector<GameApiItem*> a4 = append_vectors(a3, v5);
8667 std::vector<GameApiItem*> a5 = append_vectors(a4, v6);
8668 std::vector<GameApiItem*> a51 = append_vectors(a5, v51);
8669 std::vector<GameApiItem*> a6 = append_vectors(a51, v7);
8670 std::vector<GameApiItem*> a7 = append_vectors(a6, v8);
8671 std::vector<GameApiItem*> a8 = append_vectors(a7, v9);
8672 std::vector<GameApiItem*> a9 = append_vectors(a8, va);
8673 std::vector<GameApiItem*> aa = append_vectors(a9, vb);
8674 std::vector<GameApiItem*> ab = append_vectors(aa, vc);
8675 std::vector<GameApiItem*> ac = append_vectors(ab, vd);
8676 std::vector<GameApiItem*> ad = append_vectors(ac, ve);
8677 std::vector<GameApiItem*> ae = append_vectors(ad, vf);
8678 std::vector<GameApiItem*> af = append_vectors(ae, vg);
8679 std::vector<GameApiItem*> ag = append_vectors(af, vh);
8680 std::vector<GameApiItem*> ah = append_vectors(ag, vi);
8681 std::vector<GameApiItem*> ai = append_vectors(ah, vj);
8682 std::vector<GameApiItem*> aj = append_vectors(ai, vk);
8683 std::vector<GameApiItem*> ak = append_vectors(aj, vl);
8848 std::vector<std::string> vec2;
8849 std::vector<std::string> vec2_0;
8850 std::vector<std::string> vec3;
8859 FunctionsData *dt = (FunctionsData*)ptr;
8860 GameApi::W w = dt->gui->
list_item_opened(130-5, dt->label, dt->atlas, dt->atlas_bm, dt->vec2, dt->vec3, dt->atlas2, dt->atlas_bm2, dt->insert,
false,dt->outer, dt->vec2_0);
8863GameApi::W w2_func(
void *ptr)
8865 FunctionsData *dt = (FunctionsData*)ptr;
8867 GameApi::W
e = dt->gui->
empty();
8868 GameApi::W w = dt->gui->
list_item_opened(130-5, dt->label, dt->atlas, dt->atlas_bm, dt->vec2, dt->vec3, dt->atlas2, dt->atlas_bm2,
e,
true, dt->outer, dt->vec2_0);
8873EXPORT GameApi::W
functions_widget(GameApi::GuiApi &gui, std::string label, std::vector<GameApiItem*> vec, GameApi::FtA atlas, GameApi::BM atlas_bm, GameApi::FtA atlas2, GameApi::BM atlas_bm2, GameApi::W insert, GameApi::W *outer)
8875 std::vector<std::string> vec2;
8876 std::vector<std::string> vec2_0;
8877 std::vector<std::string> vec3;
8879 for(
int i=0;i<s;i++)
8881 GameApiItem *item = vec[i];
8882 vec2.push_back(item->
Name(0));
8883 vec2_0.push_back(item->
FuncName(0));
8885 std::string typestr =
"(";
8886 for(
int j=0;j<sp;j++)
8888 std::string type = item->
ParamType(0, j);
8890 if (type.size()<=4 && type.size()>0 && type[0]>=
'A' && type[0]<=
'Z')
8892 if (typestr.size()!=1)
8896 if (type.size()>2 && type[0]==
'[' && type[type.size()-1]==
']')
8898 if (type[1]==
'[' && type[type.size()-2]==
']') type = type.substr(1, type.size()-2);
8900 if (typestr.size()!=1)
8907 vec3.push_back(typestr);
8909 FunctionsData *dt =
new FunctionsData;
8911 std::string
num =
"";
8913 std::stringstream ss; ss << s;
num = ss.str() +
" ";
8915 dt->label =
num + label;
8917 dt->atlas_bm = atlas_bm;
8919 dt->vec2_0 = vec2_0;
8921 dt->atlas2 = atlas2;
8922 dt->atlas_bm2 = atlas_bm2;
9033 void activate() { activated =
true; }
9034 void deactivate() { activated =
false; }
9035 void update(Point2d mouse_pos,
int button,
int ch,
int type,
int mouse_wheel_y)
9042 if (!state && button==-1)
9046 if (button==0 && type==1025 && state)
9048 f(
int(mouse_pos.
x),
int(mouse_pos.
y));
9066 std::function<void(
int,
int)>
f;
9083 std::vector<std::pair<std::string,std::string> > vec;
9087 int s = funcs.size();
9088 for(
int i=0;i<s;i++)
9091 std::string apiname = i2->
ApiName(0);
9092 std::string funcname = i2->
FuncName(0);
9094 vec.push_back(std::make_pair(apiname +
"." + funcname,
name));
9105 for(
int i=0;i<ss;i++)
9107 if (s[i]==
'(') level++;
9108 if (s[i]==
')') level--;
9109 if (level==0 && s[i]==ch)
return i;
9114std::vector<std::string> g_float_eval_env;
9115std::vector<std::string> g_int_eval_env;
9116std::vector<std::string> g_string_eval_env;
9120 if (s.size()>0 && s[0]==
'@')
return StringExprEval(s.substr(1,s.size()-1));
9122 if (s.size()>0 && s[0]==
' ')
return IntExprEval(s.substr(1,s.size()-1));
9123 if (s.size()>0 && s[s.size()-1]==
' ')
return IntExprEval(s.substr(0,s.size()-1));
9125 if (s.size()==2 && s[0]==
'&' && s[1]>=
'1' && s[1]<=
'5')
9128 std::string v = g_int_eval_env.size()>val?g_int_eval_env[val]:
"";
9138 if (s.size()>0 && s[0]==
'@')
return StringExprEval(s.substr(1,s.size()-1));
9139 if (s.size()==2 && s[0]==
'$' && s[1]>=
'1' && s[1]<=
'5')
9142 std::string v = g_string_eval_env.size()>val?g_string_eval_env[val]:
"";
9151 if (s.size()>0 && s[0]==
'@')
return FloatExprEval(s.substr(1,s.size()-1));
9152 if (s.size()>0 && s[0]==
' ')
return FloatExprEval(s.substr(1,s.size()-1));
9153 if (s.size()>0 && s[s.size()-1]==
' ')
return FloatExprEval(s.substr(0,s.size()-1));
9154 if (s.size()>0 && s[0]==
'-') {
9156 std::stringstream ss(s2);
9160 std::stringstream ss2;
9165 if (s.size()>2 && s[0]==
'(' && s[s.size()-1]==
')')
9171 std::string start = s.substr(0,vala);
9172 std::string end = s.substr(vala+1);
9175 std::stringstream ss(res1);
9176 std::stringstream ss2(res2);
9177 float val1=0.0, val2=0.0;
9180 std::stringstream res;
9188 std::string start = s.substr(0,valb);
9189 std::string end = s.substr(valb+1);
9192 std::stringstream ss(res1);
9193 std::stringstream ss2(res2);
9194 float val1=0.0, val2=0.0;
9197 std::stringstream res;
9205 std::string start = s.substr(0,valc);
9206 std::string end = s.substr(valc+1);
9209 std::stringstream ss(res1);
9210 std::stringstream ss2(res2);
9211 float val1=0.0, val2=0.0;
9214 std::stringstream res;
9222 std::string start = s.substr(0,vald);
9223 std::string end = s.substr(vald+1);
9226 std::stringstream ss(res1);
9227 std::stringstream ss2(res2);
9228 float val1=0.0, val2=0.0;
9231 std::stringstream res;
9237 if (s.size()==2 && s[0]==
'%' && s[1]>=
'1' && s[1]<=
'5')
9240 std::string v = g_float_eval_env.size()>val?g_float_eval_env[val]:
"";
9247struct CharConv { std::string repl; std::string
ch_str;
char ch; };
9249class ConversionTable :
public ConversionTableInterface {
9251 static int find_str_pos(std::string val,
int pos, std::string repl)
9253 int s = val.size()-repl.size()+1;
9254 for(
int i=pos;i<s;i++)
9256 int s2 = repl.size();
9258 for(
int j=0;j<s2;j++)
9260 if (val[i+j]!=repl[j]) { found=
false;
break; }
9262 if (found)
return i;
9267 static std::string replace_str3(std::string val, std::string repl, std::string subst)
9271 if (pos==-1)
return val;
9272 val = val.replace(pos,repl.size(),subst);
9278 int get_size()
const {
return conv_table.size(); }
9279 std::string
get_label(
int i)
const {
return conv_table[i].repl; }
9280 virtual std::string get_str_ch(
int i)
const {
return conv_table[i].ch_str; }
9281 virtual char get_ch(
int i)
const {
return conv_table[i].ch; }
9283 virtual std::string convert_labels_to_chars(std::string
str)
const
9285 int s7 = get_size();
9286 for(
int i=0;i<s7;i++)
9292 virtual int find_last_location(std::string
str)
const
9300 for(
int i=0;i<s;i++) {
9304 if (res!=-1) { pos2=std::max(pos2,res); found=
true; }
9306 if (!found)
break;
else loc=pos2;
9312 virtual bool insert_label_to_string(std::string *
str,
char ch)
const
9315 int s8 = get_size();
9316 for(
int i=0;i<s8;i++)
9321 int s9=label.size();
9322 for(
int j=0;j<s9;j++)
9324 str->push_back(label[j]);
9332 std::vector<CharConv> conv_table = {
9333 {
"{032}",
" ",
' ' },
9334 {
"{063}",
"?",
'?' },
9335 {
"{035}",
"#",
'#' },
9337 {
"{059}",
";",
';' },
9338 {
"{124}",
"|",
'|' },
9339 {
"{123}",
"{",
'{' },
9340 {
"{125}",
"}",
'}' },
9341 {
"{091}",
"[",
'[' },
9342 {
"{093}",
"]",
']' },
9343 {
"{044}",
",",
',' },
9344 {
"{034}",
"\"",
'"' }
9347ConversionTable g_conv_table_impl;
9359std::string g_current_language =
"fi";
9364std::vector<KeyData> finnish_scancodes =
9367 { 0, 30,
"1",
"!",
"" },
9368 { 1, 31,
"2",
"\"",
"@" },
9369 { 2, 32,
"3",
"#",
"£" },
9370 { 3, 33,
"4",
"$",
"¤" },
9371 { 4, 34,
"5",
"%",
"€" },
9372 { 5, 35,
"6",
"&",
"" },
9373 { 6, 36,
"7",
"/",
"{" },
9374 { 7, 37,
"8",
"(",
"[" },
9375 { 8, 38,
"9",
")",
"]" },
9376 { 9, 39,
"0",
"=",
"}" },
9379 { 10, 45,
"+",
"?",
"\\" },
9380 { 11, 46,
"´",
"`",
"" },
9383 { 12, 4,
"q",
"Q",
"" },
9384 { 13, 5,
"w",
"W",
"" },
9385 { 14, 6,
"e",
"E",
"€" },
9386 { 15, 7,
"r",
"R",
"" },
9387 { 16, 8,
"t",
"T",
"" },
9388 { 17, 9,
"y",
"Y",
"" },
9389 { 18, 10,
"u",
"U",
"" },
9390 { 19, 11,
"i",
"I",
"" },
9391 { 20, 12,
"o",
"O",
"" },
9392 { 21, 13,
"p",
"P",
"" },
9395 { 22, 14,
"\xE5",
"\xC5",
"" },
9396 { 23, 15,
"\xF6",
"\xD6",
"" },
9397 { 24, 16,
"\xE4",
"\xC4",
"" },
9400 { 25, 17,
"a",
"A",
"" },
9401 { 26, 18,
"s",
"S",
"" },
9402 { 27, 19,
"d",
"D",
"" },
9403 { 28, 20,
"f",
"F",
"" },
9404 { 29, 21,
"g",
"G",
"" },
9405 { 30, 22,
"h",
"H",
"" },
9406 { 31, 23,
"j",
"J",
"" },
9407 { 32, 24,
"k",
"K",
"" },
9408 { 33, 25,
"l",
"L",
"" },
9411 { 34, 26,
"z",
"Z",
"" },
9412 { 35, 27,
"x",
"X",
"" },
9413 { 36, 28,
"c",
"C",
"" },
9414 { 37, 29,
"v",
"V",
"" },
9415 { 38, 30,
"b",
"B",
"" },
9416 { 39, 31,
"n",
"N",
"" },
9417 { 40, 32,
"m",
"M",
"" },
9420 { 41, 44,
",",
";",
"" },
9421 { 42, 45,
".",
":",
"" },
9422 { 43, 46,
"-",
"_",
"" },
9427std::vector<KeyData> us_scancodes =
9430 { 0, 30,
"1",
"!",
"" },
9431 { 1, 31,
"2",
"@",
"" },
9432 { 2, 32,
"3",
"#",
"" },
9433 { 3, 33,
"4",
"$",
"" },
9434 { 4, 34,
"5",
"%",
"" },
9435 { 5, 35,
"6",
"^",
"" },
9436 { 6, 36,
"7",
"&",
"" },
9437 { 7, 37,
"8",
"*",
"" },
9438 { 8, 38,
"9",
"(",
"" },
9439 { 9, 39,
"0",
")",
"" },
9442 { 10, 45,
"-",
"_",
"" },
9443 { 11, 46,
"=",
"+",
"" },
9445 { 12, 47,
"[",
"{",
"" },
9446 { 13, 48,
"]",
"}",
"" },
9447 { 14, 49,
"\\",
"|",
"" },
9449 { 15, 51,
";",
":",
"" },
9450 { 16, 52,
"'",
"\"",
"" },
9451 { 17, 53,
"`",
"~",
"" },
9453 { 18, 54,
",",
"<",
"" },
9454 { 19, 55,
".",
">",
"" },
9455 { 20, 56,
"/",
"?",
"" },
9458 { 21, 4,
"a",
"A",
"" },
9459 { 22, 5,
"b",
"B",
"" },
9460 { 23, 6,
"c",
"C",
"" },
9461 { 24, 7,
"d",
"D",
"" },
9462 { 25, 8,
"e",
"E",
"" },
9463 { 26, 9,
"f",
"F",
"" },
9464 { 27, 10,
"g",
"G",
"" },
9465 { 28, 11,
"h",
"H",
"" },
9466 { 29, 12,
"i",
"I",
"" },
9467 { 30, 13,
"j",
"J",
"" },
9468 { 31, 14,
"k",
"K",
"" },
9469 { 32, 15,
"l",
"L",
"" },
9471 { 33, 16,
"m",
"M",
"" },
9472 { 34, 17,
"n",
"N",
"" },
9473 { 35, 18,
"o",
"O",
"" },
9474 { 36, 19,
"p",
"P",
"" },
9475 { 37, 20,
"q",
"Q",
"" },
9476 { 38, 21,
"r",
"R",
"" },
9477 { 39, 22,
"s",
"S",
"" },
9478 { 40, 23,
"t",
"T",
"" },
9479 { 41, 24,
"u",
"U",
"" },
9480 { 42, 25,
"v",
"V",
"" },
9481 { 43, 26,
"w",
"W",
"" },
9482 { 44, 27,
"x",
"X",
"" },
9483 { 45, 28,
"y",
"Y",
"" },
9484 { 46, 29,
"z",
"Z",
"" },
9489std::vector<KeyData> german_scancodes =
9492 { 0, 30,
"1",
"!",
"" },
9493 { 1, 31,
"2",
"\"",
"²" },
9494 { 2, 32,
"3",
"§",
"³" },
9495 { 3, 33,
"4",
"$",
"" },
9496 { 4, 34,
"5",
"%",
"" },
9497 { 5, 35,
"6",
"&",
"" },
9498 { 6, 36,
"7",
"/",
"{" },
9499 { 7, 37,
"8",
"(",
"[" },
9500 { 8, 38,
"9",
")",
"]" },
9501 { 9, 39,
"0",
"=",
"}" },
9504 { 10, 45,
"ß",
"?",
"\\" },
9505 { 11, 46,
"´",
"`",
"" },
9507 { 12, 47,
"ü",
"Ü",
"" },
9508 { 13, 48,
"+",
"*",
"~" },
9509 { 14, 49,
"#",
"'",
"" },
9511 { 15, 51,
"ö",
"Ö",
"" },
9512 { 16, 52,
"ä",
"Ä",
"" },
9513 { 17, 53,
"^",
"°",
"" },
9515 { 18, 54,
",",
";",
"" },
9516 { 19, 55,
".",
":",
"" },
9517 { 20, 56,
"-",
"_",
"" },
9520 { 21, 4,
"a",
"A",
"" },
9521 { 22, 5,
"b",
"B",
"" },
9522 { 23, 6,
"c",
"C",
"" },
9523 { 24, 7,
"d",
"D",
"" },
9524 { 25, 8,
"e",
"E",
"€" },
9525 { 26, 9,
"f",
"F",
"" },
9526 { 27, 10,
"g",
"G",
"" },
9527 { 28, 11,
"h",
"H",
"" },
9528 { 29, 12,
"i",
"I",
"" },
9529 { 30, 13,
"j",
"J",
"" },
9530 { 31, 14,
"k",
"K",
"" },
9531 { 32, 15,
"l",
"L",
"" },
9533 { 33, 16,
"m",
"M",
"" },
9534 { 34, 17,
"n",
"N",
"" },
9535 { 35, 18,
"o",
"O",
"" },
9536 { 36, 19,
"p",
"P",
"" },
9537 { 37, 20,
"q",
"Q",
"@" },
9538 { 38, 21,
"r",
"R",
"" },
9539 { 39, 22,
"s",
"S",
"" },
9540 { 40, 23,
"t",
"T",
"" },
9541 { 41, 24,
"u",
"U",
"" },
9542 { 42, 25,
"v",
"V",
"" },
9543 { 43, 26,
"w",
"W",
"" },
9544 { 44, 27,
"x",
"X",
"" },
9545 { 45, 28,
"z",
"Z",
"" },
9546 { 46, 29,
"y",
"Y",
"" },
9550std::vector<KeyData> choose_keydata()
9552 if (g_current_language==
"fi")
return finnish_scancodes;
9553 if (g_current_language==
"us")
return us_scancodes;
9554 if (g_current_language==
"ge")
return german_scancodes;
9555 std::cout <<
"Warning: " << g_current_language <<
" language not available at choose_keydata()." << std::endl;
9556 return finnish_scancodes;
char chars[]
Definition test.cpp:102
P func(int c, EveryApi &ev)
Definition test.cpp:59
Env e
Definition Common.cc:2
LowApi * g_low
Definition GameApi_low.cc:1684
Point2d pt(const FT_Vector *v)
Definition FreeType2.cc:459
void rectangle(Matrix m, float x, float y, FaceStore &s)
Definition Functions.cc:66
std::vector< GameApi::TF > g_tf_instances
Definition GameApi_gui.cc:4704
std::string str_tolower(std::string s)
Definition GameApi_pl.cc:18195
std::vector< GameApiItem * > all_functions(GameApi::EveryApi &ev)
Definition GameApi_gui.cc:8638
IMPORT ConversionTableInterface * g_conv_table
Definition GameApi_fnt.cc:614
std::string GetContentInstallDir(bool b)
float g_progress_bar_mult_builder
Definition GameApi.cc:45922
IMPORT AllFunctionsServiceInterface * g_all_functions_service
Definition GameApi.cc:46279
bool g_is_quake
Definition GameApi.cc:25263
std::string ch_str(std::vector< std::string > vec, int i)
Definition GameApi.cc:30160
int g_time_id
Definition GameApi_gltf.cc:14949
void call_all_mlguiwidget_cbs()
Definition GameApi.cc:18259
bool g_inside_icon_display
Definition GameApi.cc:30625
std::string find_param_name(GameApi::EveryApi &ev, std::string api_name, std::string func_name, int ii)
Definition GameApi_gui.cc:7189
std::string convert_script(std::string script)
Definition GameApi.cc:27532
bool g_inside_mesh_display
Definition GameApi.cc:30626
void LoadUrls_async_cbs()
Definition GameApi_gui.cc:7873
#define EXPORT
Definition GameApi.hh:334
int ELayoutEmpty
Definition GameApi_gui.cc:2662
#define IMPORT
Definition GameApi.hh:332
void clear_block(int id)
Definition GameApi_dep_add_find.cc:114
int add_block()
Definition GameApi_dep_add_find.cc:33
void set_current_block(int id)
Definition GameApi_dep_add_find.cc:65
int get_current_block()
Definition GameApi_dep_add_find.cc:110
std::string stripprefix(std::string s)
Definition GameApi_dep_env.cc:2555
std::map< std::string, std::vector< unsigned char > * > load_url_buffers
Definition GameApi_gui.cc:7642
void funccall_1(std::vector< std::string > &s, GameApi::ExecuteEnv &e, std::vector< std::string > param_name)
Definition GameApi_cmd.cc:87
MACRO2(GameApi::LI, ev.lines_api.from_polygon(ev.polygon_api.p_empty())) MACRO2(GameApi std::pair< std::string, std::string > CodeGen_1(GameApi::EveryApi &ev, std::vector< std::string > params, std::vector< std::string > param_names, std::vector< std::string > param_type, std::vector< std::string > param_exprs, std::string return_type, std::string api_name, std::string func_name, int j)
Definition GameApi_cmd.cc:45
int ret_type_count(std::string s)
Definition GameApi_gui.cc:4116
DelApiItemF g_api_item_deleter
Definition GameApi_gui.cc:8618
std::string FloatExprEval(std::string s)
Definition GameApi_gui.cc:9148
int find_float_ch(std::string s, char ch)
Definition GameApi_gui.cc:9102
std::vector< GameApiItem * > boolbitmapapi_functions()
Definition GameApi_cmd_bbitmap.cc:5
std::vector< GameApiItem * > bitmapapi_functions()
Definition GameApi_cmd_bitmap.cc:5
std::vector< GameApiItem * > booleanopsapi_functions()
Definition GameApi_cmd_booleanops.cc:6
std::vector< GameApiItem * > colorvolumeapi_functions()
Definition GameApi_cmd_cvolume.cc:5
std::vector< GameApiItem * > floatbitmapapi_functions()
Definition GameApi_cmd_fbitmap.cc:5
std::vector< GameApiItem * > fontapi_functions()
Definition GameApi_cmd_font.cc:5
std::vector< GameApiItem * > framebuffermoduleapi_functions()
Definition GameApi_cmd_framebuffer.cc:5
std::vector< GameApiItem * > vectorapi_functions()
Definition GameApi_cmd_vector.cc:5
std::vector< GameApiItem * > volumeapi_functions()
Definition GameApi_cmd_volume.cc:30
std::vector< GameApiItem * > textureapi_functions()
Definition GameApi_cmd_texture.cc:30
std::vector< GameApiItem * > polydistfield_functions()
Definition GameApi_cmd_pdfield.cc:4
std::vector< GameApiItem * > floatvolumeapi_functions()
Definition GameApi_cmd_fvolume.cc:29
std::vector< GameApiItem * > pointsapi_functions()
Definition GameApi_cmd_points.cc:4
std::vector< GameApiItem * > polygonapi_functions()
Definition GameApi_cmd_polygon.cc:8
std::vector< GameApiItem * > waveform_functions()
Definition GameApi_cmd_waveform.cc:5
std::vector< GameApiItem * > shadermoduleapi_functions()
Definition GameApi_cmd_material.cc:7
std::vector< GameApiItem * > linesapi_functions()
Definition GameApi_cmd_lines.cc:4
std::vector< GameApiItem * > moveapi_functions()
Definition GameApi_cmd_move.cc:5
std::vector< GameApiItem * > blocker_functions(GameApi::EveryApi &ev)
Definition GameApi_cmd_mainloop.cc:4
std::vector< GameApiItem * > pointapi_functions()
Definition GameApi_cmd_point.cc:4
std::vector< GameApiItem * > shaderapi_functions()
Definition GameApi_cmd_shader.cc:6
GameApi::P add_polygon2(GameApi::Env &e, FaceCollection *coll, int size=1)
Definition GameApi_dep_add_find.cc:1219
GameApi::M add_matrix2(GameApi::Env &e, Matrix mm)
Definition GameApi_dep_add_find.cc:1232
RenderVertexArray * find_vertex_array_render(GameApi::Env &e, GameApi::VA p)
Definition GameApi_dep_add_find.cc:2616
GameApi::W add_widget(GameApi::Env &e, GuiWidget *w)
Definition GameApi_dep_add_find.cc:818
GuiWidget * find_widget(GameApi::Env &e, GameApi::W w)
Definition GameApi_dep_add_find.cc:2082
Point * find_point(GameApi::Env &e, GameApi::PT p)
Definition GameApi_dep_add_find.cc:2784
BitmapHandle * find_bitmap(GameApi::Env &e, GameApi::BM b)
Definition GameApi_dep_add_find.cc:2456
FontAtlasInfo * find_font_atlas(GameApi::Env &e, GameApi::FtA ft)
Definition GameApi_dep_add_find.cc:2072
Bitmap< Color > * find_color_bitmap(BitmapHandle *handle, int bbm_choose)
Definition GameApi_dep_add_find.cc:2686
GameApi::ML add_main_loop(GameApi::Env &e, MainLoopItem *item)
Definition GameApi_dep_add_find.cc:797
void add_update_widget(GameApi::Env &e, GameApi::W widget, GuiWidget *w)
Definition GameApi_dep_add_find.cc:1096
MainLoopItem * find_main_loop(GameApi::Env &e, GameApi::ML ml)
Definition GameApi_dep_add_find.cc:2062
ASyncCallback * rem_async_cb(std::string url)
Definition GameApi_dep_env.cc:2507
void * process(void *ptr)
Definition GameApi_dep_env.cc:2773
del_map_interface & g_del_map
Definition GameApi_dep_env.cc:302
IMPORT std::string striphomepage(std::string url)
Definition GameApi_dep_env.cc:4365
int g_async_load_count
Definition GameApi_dep_env.cc:4090
int find_char(std::string expr, char c)
Definition GameApi_ex.cc:393
bool is_in_registered(std::string url)
Definition GameApi_gui.cc:7900
bool g_concurrent_download
Definition GameApi_gltf.cc:2008
IMPORT GameApi::PAT gameapi_temp_dir
Definition GameApi.cc:171
std::vector< GameApiItem * > fontapi_functions()
Definition GameApi_cmd_font.cc:5
std::map< std::string, int > shared_text
Definition GameApi_gui.cc:722
std::vector< GameApiItem * > polygonapi_functions1()
Definition GameApi_cmd_polygon.cc:15
std::vector< GameApiItem * > vectorapi_functions()
Definition GameApi_cmd_vector.cc:5
int ret_type_count(std::string return_type)
Definition GameApi_gui.cc:4116
std::vector< GameApiItem * > framebuffermoduleapi_functions()
Definition GameApi_cmd_framebuffer.cc:5
std::vector< GameApiItem * > volumeapi_functions()
Definition GameApi_cmd_volume.cc:30
std::vector< GameApiItem * > all_functions(GameApi::EveryApi &ev)
Definition GameApi_gui.cc:8638
bool done
Definition GameApi_gui.cc:1629
std::vector< GameApiItem * > colorvolumeapi_functions()
Definition GameApi_cmd_cvolume.cc:5
bool is_allowed(std::string chars, char ch)
Definition GameApi_gui.cc:1079
std::vector< GameApiItem * > bitmapapi_functions()
Definition GameApi_cmd_bitmap.cc:5
size dy
Definition GameApi_gui.cc:1727
const float keypress_rot_speed
Definition GameApi_gui.cc:73
std::vector< GameApiItem * > textureapi_functions()
Definition GameApi_cmd_texture.cc:30
std::string StringExprEval(std::string s)
Definition GameApi_gui.cc:9136
void set_value(std::string value)
Definition GameApi_gui.cc:1438
std::vector< GameApiItem * > polydistfield_functions()
Definition GameApi_cmd_pdfield.cc:4
IMPORT bool g_reload_edit_dialog
Definition GameApi_gui.cc:1072
std::string IntExprEval(std::string s)
Definition GameApi_gui.cc:9118
std::vector< GameApiItem * > floatvolumeapi_functions()
Definition GameApi_cmd_fvolume.cc:29
std::vector< GameApiItem * > pointsapi_functions()
Definition GameApi_cmd_points.cc:4
int render_to_bitmap()
Definition GameApi_gui.cc:1434
std::vector< GameApiItem * > floatbitmapapi_functions()
Definition GameApi_cmd_fbitmap.cc:5
std::vector< GameApiItem * > polygonapi_functions()
Definition GameApi_cmd_polygon.cc:8
std::vector< GameApiItem * > booleanopsapi_functions()
Definition GameApi_cmd_booleanops.cc:6
std::string g_searchstring
Definition GameApi_gui.cc:328
IMPORT ConversionTableInterface * g_conv_table
Definition GameApi_gui.cc:9348
std::vector< GameApiItem * > waveform_functions()
Definition GameApi_cmd_waveform.cc:5
std::vector< GameApiItem * > shadermoduleapi_functions()
Definition GameApi_cmd_material.cc:7
IMPORT std::string g_dragdrop_filename
Definition GameApi_gui.cc:1068
std::vector< GameApiItem * > shaderapi_functions()
Definition GameApi_cmd_shader.cc:6
EditorGuiWidgetAtlas GuiWidgetForward render()
Definition GameApi_gui.cc:1412
void update(Point2d mouse, int button, int ch, int type, int mouse_wheel_y)
Definition GameApi_gui.cc:1424
std::vector< GameApiItem * > linesapi_functions()
Definition GameApi_cmd_lines.cc:4
std::vector< GameApiItem * > moveapi_functions()
Definition GameApi_cmd_move.cc:5
std::vector< GameApiItem * > blocker_functions(GameApi::EveryApi &ev)
Definition GameApi_cmd_mainloop.cc:4
std::string unique_id_apiitem()
Definition accel.cc:42
IMPORT bool g_dragdrop_enabled
Definition GameApi_gui.cc:1067
std::vector< GameApiItem * > polygonapi_functions2()
Definition GameApi_cmd_polygon2.cc:5
std::vector< GameApiItem * > boolbitmapapi_functions()
Definition GameApi_cmd_bbitmap.cc:5
std::string g_temp44
Definition GameApi_gui.cc:1070
std::vector< GameApiItem * > pointapi_functions()
Definition GameApi_cmd_point.cc:4
const unsigned int c_canvas_item_text_button2
Definition GameApi_gui.hh:14
const unsigned int c_tooltip_button
Definition GameApi_gui.hh:7
const unsigned int c_canvas_item_node_1_2
Definition GameApi_gui.hh:18
const unsigned int c_dialog_button_1
Definition GameApi_gui.hh:21
const unsigned int c_canvas_item_text_button
Definition GameApi_gui.hh:13
const unsigned int c_list_item_title2
Definition GameApi_gui.hh:10
const unsigned int c_canvas_item_node_1
Definition GameApi_gui.hh:17
const unsigned int c_canvas_item
Definition GameApi_gui.hh:11
const unsigned int c_tooltip_button2
Definition GameApi_gui.hh:8
const unsigned int c_dialog_button_2
Definition GameApi_gui.hh:22
const unsigned int c_canvas_item_node_0_2
Definition GameApi_gui.hh:16
const unsigned int c_dialog_1_2
Definition GameApi_gui.hh:20
const unsigned int c_list_item_title
Definition GameApi_gui.hh:9
const unsigned int c_dialog_1
Definition GameApi_gui.hh:19
const unsigned int c_canvas_item_node_0
Definition GameApi_gui.hh:15
const unsigned int c_canvas_item2
Definition GameApi_gui.hh:12
std::string unique_id()
Definition GameApi_shm.cc:50
#define Low_SDL_JOYAXISMOTION
Definition GameApi_low.hh:585
@ Low_GL_DEPTH_TEST
Definition GameApi_low.hh:61
@ Low_GL_SCISSOR_TEST
Definition GameApi_low.hh:104
#define Low_SDL_JOYBALLMOTION
Definition GameApi_low.hh:586
bool g_inside_ml_widget
Definition GameApi_gui.cc:1692
float arg(Complex z)
Definition GameApi_pl.cc:31413
std::vector< Item * > functions()
Definition accel.cc:335
std::string api_name()
Definition accel.cc:318
PML or_elem(PML p1, PML p2)
Definition accel.cc:820
unsigned int color_1(int pointnum, PT pos)
Definition test.cpp:7
std::ostream & operator<<(std::ostream &, Catch_global_namespace_dummy)
Object call(Vector t_params) const
Calls the function with the given set of parameters and returns the value;.
void info(std::string info)
Definition check.cc:24
void error(std::string err, std::string fail_reason)
Definition check.cc:18
int value
Definition GameApi_gui.cc:2473
int key
Definition GameApi_gui.cc:2473
virtual std::vector< GameApiItem * > & get_all_functions(GameApi::EveryApi &ev)=0
virtual int SizeY() const =0
virtual int SizeX() const =0
Definition GraphI.hh:2215
Definition GameApi_fbo.cc:158
void first_frame(int i)
Definition GameApi_gui.cc:1711
std::vector< CollectInterface * > vec
Definition GameApi_fbo.cc:185
int count(int i) const
Definition GameApi_gui.cc:1717
void register_first_frame(CollectInterface *i)
Definition GameApi_gui.cc:1703
std::vector< CollectInterface * > vec2
Definition GameApi_fbo.cc:186
void register_obj(CollectInterface *i)
Definition GameApi_gui.cc:1700
void execute(int i)
Definition GameApi_gui.cc:1706
static void set(float &target, std::string s, bool allow_expr, std::string &expr)
Definition GameApi_gui.cc:931
static std::string error(const std::string &target, const std::string &dd)
Definition GameApi_gui.cc:933
static void get(const float &target, std::string &s, bool allow_expr, std::string &expr)
Definition GameApi_gui.cc:932
static std::string error(const std::string &target, const std::string &dd)
Definition GameApi_gui.cc:942
static void get(const int &target, std::string &s, bool allow_expr, std::string &expr)
Definition GameApi_gui.cc:941
static void set(int &target, std::string s, bool allow_expr, std::string &expr)
Definition GameApi_gui.cc:940
static std::string error(const std::string &target, const std::string &dd_ext)
Definition GameApi_gui.cc:921
static void get(const std::string &target, std::string &s, bool allow_expr, std::string &expr)
Definition GameApi_gui.cc:920
static void set(std::string &target, std::string s, bool allow_expr, std::string &expr)
Definition GameApi_gui.cc:919
Definition GameApi_gui.cc:909
static std::string error(const std::string &target, const std::string &dd)
Definition GameApi_gui.cc:913
static void set(T &target, std::string s, bool allow_expr, std::string &expr)
Definition GameApi_gui.cc:911
static void get(const T &target, std::string &s, bool allow_expr, std::string &expr)
Definition GameApi_gui.cc:912
virtual std::string convert_labels_to_chars(std::string str) const =0
Definition GameApi_gui.cc:199
int calc_top(char ch2)
Definition GameApi_gui.cc:257
void check_letters(std::string ss)
Definition GameApi_gui.cc:227
int calc_one_height()
Definition GameApi_gui.cc:294
int calc_all_height()
Definition GameApi_gui.cc:282
void render_w(int p, GameApi::W w, char ch2)
Definition GameApi_gui.cc:301
DynamicTextGuiWidget(GameApi::Env &e, GameApi::EveryApi &ev, GameApi::GuiApi &gui, std::string need_letters, std::string *dyn_text, void(*fptr)(void *, float mouse_x, float mouse_y, int button, int ch, int type, int mouse_wheel_y), void *user_ptr, GameApi::FtA atlas, GameApi::BM atlas_bm, int x_gap)
Definition GameApi_gui.cc:201
void update(Point2d mouse, int button, int ch, int type, int mouse_wheel_y)
Definition GameApi_gui.cc:216
void render()
Definition GameApi_gui.cc:241
int calc_one_top(char ch)
Definition GameApi_gui.cc:275
void add_letter(int ch)
Definition GameApi_gui.cc:204
int calc_all_top()
Definition GameApi_gui.cc:264
virtual std::string Name(int i) const =0
virtual std::string ApiName(int i) const =0
virtual int ParamCount(int i) const =0
virtual std::string ReturnType(int i) const =0
virtual std::string ParamDefault(int i, int p) const =0
virtual std::string ParamName(int i, int p) const =0
virtual std::string FuncName(int i) const =0
virtual std::string ParamType(int i, int p) const =0
virtual int Execute(GameApi::Env &ee, GameApi::EveryApi &ev, std::vector< std::string > params, GameApi::ExecuteEnv &e, int j)=0
Definition GraphI.hh:2078
Definition GameApi.hh:362
Definition GameApi.hh:2254
IMPORT W generic_editor(EveryApi &ev, EditTypes &target, FtA atlas, BM atlas_bm, std::string type, int x_gap, FtA atlas_tiny, BM atlas_tiny_bm, int sy, W &click_target)
Definition GameApi_gui.cc:5981
IMPORT W colorvolumeapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8976
IMPORT W bounding_box(W w)
Definition GameApi_gui.cc:2377
IMPORT W or_elem(W(*w1_func)(void *), W(*w2_func)(void *), void *data)
Definition GameApi_gui.cc:6727
IMPORT std::string boolbitmapapi_functions_item_label(int i)
Definition GameApi_gui.cc:8798
IMPORT int size_x(W w)
Definition GameApi_gui.cc:6845
IMPORT W multiline_string_editor(std::string allowed_chars, std::string &target, FI font, int x_gap, int line_height)
Definition GameApi_gui.cc:4740
IMPORT W ml(ML p, SH sh, SH sh2, SH sh_2d, SH sh_arr, int sx, int sy, int screen_size_x, int screen_size_y)
Definition GameApi_gui.cc:4706
IMPORT int pos_y(W w)
Definition GameApi_gui.cc:6840
IMPORT std::string textureapi_functions_item_label(int i)
Definition GameApi_gui.cc:8708
IMPORT std::string fontapi_functions_item_label(int i)
Definition GameApi_gui.cc:8716
IMPORT W pts_dialog(PTS p, SH sh, int screen_size_x, int screen_size_y, W &close_button, FtA atlas, BM atlas_bm, W &codegen_button, W &collect_button)
Definition GameApi_gui.cc:5447
IMPORT W layout_lh(W item, int left, int top, int width, int height, int right, int bottom, int(*fptr_l)(void *), int(*fptr_H)(void *), void *ctx1, void *ctx2)
Definition GameApi_gui.cc:6104
IMPORT std::string linesapi_functions_item_label(int i)
Definition GameApi_gui.cc:8752
IMPORT W floatvolumeapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8972
IMPORT void set_dynamic_param(W w, int id, float val)
Definition GameApi_gui.cc:6942
IMPORT W canvas(int sx, int sy)
Definition GameApi_gui.cc:3735
IMPORT W directory_view(std::vector< std::string > dir_items, int &selection, std::vector< W > &clicks, FtA atlas, BM atlas_bm)
Definition GameApi_gui.cc:5002
IMPORT W floatbitmapapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:9015
IMPORT int get_size2(W w)
Definition GameApi_gui.cc:6957
IMPORT W overlap(EveryApi &ev, std::vector< W > vec)
Definition GameApi_gui.cc:4571
IMPORT W array_y(std::vector< W > arr, int y_gap, bool heavy=false)
Definition GameApi_gui.cc:6139
IMPORT W license_item(std::string filename, std::string &license_url, std::string &author, FtA atlas, BM atlas_bm, FtA atlas2, BM atlas_bm2)
Definition GameApi_gui.cc:4152
IMPORT W list_item_opened(int sx, std::string label, FtA atlas, BM atlas_bm, std::vector< std::string > subitems, std::vector< std::string > subitems_tooltip, FtA atlas2, BM atlas_bm2, W insert, bool hide, W *redraw_w, std::vector< std::string > subitems_funcname)
Definition GameApi_gui.cc:3823
IMPORT W fontapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8963
IMPORT W line(W target1, int delta_x, int delta_y, W target2, int delta2_x, int delta2_y, SH sh, SH old_sh)
Definition GameApi_gui.cc:3727
IMPORT W bitmapapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8933
IMPORT W linesapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8994
IMPORT W gradient(int sx, int sy, PT pos_1, PT pos_2, unsigned int colot_1, unsigned int color_2)
Definition GameApi_gui.cc:6621
IMPORT W polygon_dialog(P p, SH sh, int screen_size_x, int screen_size_y, W &close_button, FtA atlas, BM atlas_bm, W &codegen_button, W &collect_button, W &mem)
Definition GameApi_gui.cc:5175
IMPORT void set_index(W w, int j)
Definition GameApi_gui.cc:6967
IMPORT W download_bar(GameApi::EveryApi &ev, std::vector< std::string > titles, std::vector< W > &close_button, std::vector< W > &buttons, FtA atlas, BM atlas_bm, int active_tab, std::vector< float > progress)
Definition GameApi_gui.cc:5025
IMPORT int size_y(W w)
Definition GameApi_gui.cc:6850
IMPORT W hide_nonsearchable(W w, std::string label, W *redraw_w)
Definition GameApi_gui.cc:4605
IMPORT W boolbitmapapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:9011
IMPORT W lines_dialog(LI p, SH sh, int screen_size_x, int screen_size_y, W &close_button, FtA atlas, BM atlas_bm, W &codegen_button, W &collect_button)
Definition GameApi_gui.cc:5404
IMPORT std::string pointapi_functions_item_label(int i)
Definition GameApi_gui.cc:8812
IMPORT W blockerapi_functions_list_item(GameApi::EveryApi &ev, FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8941
IMPORT W moveapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8956
IMPORT W progress_dialog(int sx, int sy, FtA atlas, BM atlas_bm, std::vector< std::string > vec, int val, int max)
Definition GameApi_gui.cc:4326
IMPORT W framebuffermoduleapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8990
IMPORT int pos_x(W w)
Definition GameApi_gui.cc:6835
IMPORT W booleanopsapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8951
IMPORT W icon_shared_noscale(BM bitmap, int key)
Definition GameApi_gui.cc:4674
IMPORT W layer(W w1, W w2)
Definition GameApi_gui.cc:6123
IMPORT W navi_bar(EveryApi &ev, std::vector< std::string > titles, W &back_button, W &forward_button, W &save_button, std::string &url, W &url_button, std::vector< W > &close_button, std::vector< W > &tab_change_button, W &new_tab_button, std::vector< std::string > bookmark_labels, std::vector< std::string > bookmark_urls, FtA atlas, BM atlas_bm, int &active_tab)
Definition GameApi_gui.cc:5082
IMPORT W insert_widget(W item, std::function< void(int, int)> f)
Definition GameApi_gui.cc:9069
IMPORT W layout_wh(W item, int left, int top, int width, int height, int right, int bottom, int(*fptr_W)(void *), int(*fptr_H)(void *), void *ctx1, void *ctx2)
Definition GameApi_gui.cc:6090
IMPORT W window_decoration(int sx, int sy, std::string label, FtA atlas, BM atlas_bm)
Definition GameApi_gui.cc:5366
IMPORT W vectorapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:9006
IMPORT std::string colorvolumeapi_functions_item_label(int i)
Definition GameApi_gui.cc:8789
IMPORT std::string polygonapi_functions_item_label(int i)
Definition GameApi_gui.cc:8760
IMPORT W va_dialog(VA p, SH sh, int screen_size_x, int screen_size_y, W &close_button, FtA atlas, BM atlas_bm, W &codegen_button, W &collect_button)
Definition GameApi_gui.cc:5232
IMPORT void update_progress_dialog(volatile W &w, int sx, int sy, FtA atlas, BM atlas_bm, std::vector< std::string > vec, int val, int max, int process)
Definition GameApi_gui.cc:4438
IMPORT W shadermoduleapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8982
IMPORT W point_editor(float &x, float &y, float &z, FtA atlas, BM atlas_bm, int x_gap)
Definition GameApi_gui.cc:6054
IMPORT void set_pos(W w, float px, float py)
Definition GameApi_gui.cc:6855
IMPORT W scrollbar_x(int sx, int sy, int area_x)
Definition GameApi_gui.cc:6737
IMPORT W scrollbar_y(int sx, int sy, int area_y)
Definition GameApi_gui.cc:6733
IMPORT std::string framebuffermoduleapi_functions_item_label(int i)
Definition GameApi_gui.cc:8738
IMPORT std::string vectorapi_functions_item_label(int i)
Definition GameApi_gui.cc:8819
IMPORT W timed_visibility(W orig, W(*timed_widget_func)(void *), void *data, W insert, float start_duration, float duration, float dx)
Definition GameApi_gui.cc:3669
IMPORT W layout(W item, int left, int top, int width, int height, int right, int bottom)
Definition GameApi_gui.cc:6080
IMPORT int get_index(W w)
Definition GameApi_gui.cc:6952
IMPORT W alt(std::vector< W > vec, int *choose)
Definition GameApi_gui.cc:4626
IMPORT W right_align(W item, int sx)
Definition GameApi_gui.cc:5793
IMPORT W va(VA p, SH sh, int sx, int sy, int screen_size_x, int screen_size_y)
Definition GameApi_gui.cc:4699
IMPORT W pointapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:9002
IMPORT W int_editor(int &target, std::string &target_expr, FtA atlas, BM atlas_bm, int x_gap, int noneditnum=0)
Definition GameApi_gui.cc:4923
IMPORT W copy_paste_dialog(SH sh, W &close_button, FI font, FtA atlas, BM atlas_bm, std::string &edit)
Definition GameApi_gui.cc:4961
IMPORT std::string bitmapapi_functions_item_label(int i)
Definition GameApi_gui.cc:8686
IMPORT void render(W w)
Definition GameApi_gui.cc:6879
IMPORT W polygonapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:9020
IMPORT void set_size2(W w, int sz)
Definition GameApi_gui.cc:6962
IMPORT W editor_mouse_tweak(W inner, W outer, W outerouter)
Definition GameApi_gui.cc:390
IMPORT W tooltip(W orig, W insert, std::string label, FtA atlas, BM atlas_bm, int x_gap=2, float dx=40.0)
Definition GameApi_gui.cc:3712
IMPORT std::string get_id(W w)
Definition GameApi_gui.cc:6947
IMPORT float dynamic_param(W w, int id)
Definition GameApi_gui.cc:6897
IMPORT std::string pointsapi_functions_item_label(int i)
Definition GameApi_gui.cc:8745
IMPORT W waveform(std::function< float(float)> f, float start_range, float end_range, float min_value, float max_value, int sx, int sy, unsigned int true_color, unsigned int false_color)
Definition GameApi_gui.cc:6756
IMPORT W window_move(W widget, int area_x, int area_y, int area_width, int area_height)
Definition GameApi_gui.cc:4110
IMPORT W scroll_area2(W orig, int sx, int sy, int screen_y)
Definition GameApi_gui.cc:6746
IMPORT W asset_view(std::string url_or_filename)
Definition GameApi_gui.cc:5018
IMPORT void select_item(W w, int item)
Definition GameApi_gui.cc:6892
IMPORT W shader_plane(SFO p, int sx, int sy, int screen_size_x, int screen_size_y)
Definition GameApi_gui.cc:4717
IMPORT W scroll_area(W orig, int sx, int sy, int screen_y)
Definition GameApi_gui.cc:6741
IMPORT std::vector< std::pair< std::string, std::string > > get_functions_mapping(GameApi::EveryApi &ev)
Definition GameApi_gui.cc:9081
IMPORT W dynamic_text(std::string need_letters, std::string *dyn_text, void(*fptr)(void *, float mouse_x, float mouse_y, int button, int ch, int type, int mouse_wheel_y), void *user_ptr, GameApi::FtA atlas, GameApi::BM atlas_bm, int x_gap)
Definition GameApi_gui.cc:4646
IMPORT std::string shaderapi_functions_item_label(int i)
Definition GameApi_gui.cc:8731
IMPORT W rectangle(int start_x, int end_x, int start_y, int end_y, unsigned int color)
Definition GameApi_gui.cc:4014
IMPORT W lines(LI p, SH sh, int sx, int sy, int screen_size_x, int screen_size_y)
Definition GameApi_gui.cc:4722
IMPORT std::string booleanopsapi_functions_item_label(int i)
Definition GameApi_gui.cc:8827
IMPORT W main_menu(std::vector< std::string > labels, FtA atlas, BM atlas_bm)
Definition GameApi_gui.cc:6150
IMPORT W waveformapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8937
IMPORT W list_item_title(int sx, std::string label, FtA atlas, BM atlas_bm)
Definition GameApi_gui.cc:3812
IMPORT int canvas_item_index(W canvas, W item)
Definition GameApi_gui.cc:3800
IMPORT W icon_shared(BM bitmap, int key)
Definition GameApi_gui.cc:4685
IMPORT W polygondistapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:9024
IMPORT W search_panel(int sx, FtA atlas, BM atlas_bm, int x_gap, W *redraw_w)
Definition GameApi_gui.cc:4590
IMPORT int num_childs(W w)
Definition GameApi_gui.cc:6904
IMPORT W pts(PTS p, SH sh, int sx, int sy, int screen_size_x, int screen_size_y)
Definition GameApi_gui.cc:4726
IMPORT W long_editor(long &target, FtA atlas, BM atlas_bm, int x_gap, int noneditnum, std::string &expr)
Definition GameApi_gui.cc:4936
IMPORT std::string volumeapi_functions_item_label(int i)
Definition GameApi_gui.cc:8774
IMPORT W popup_menu(int x, int y, std::vector< std::string > labels, FtA atlas, BM atlas_bm, std::vector< W > &areas)
Definition GameApi_gui.cc:6790
IMPORT void update(W w, PT mouse_cursor_pos, int button, int ch, int type, int mouse_wheel_y)
Definition GameApi_gui.cc:6869
IMPORT W size(W item, int sx, int sy)
Definition GameApi_gui.cc:6118
IMPORT std::string blockerapi_functions_item_label(GameApi::EveryApi &ev, int i)
Definition GameApi_gui.cc:8700
IMPORT W volumeapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8968
IMPORT W mouse_move(W widget, int area_x, int area_y, int area_width, int area_height)
Definition GameApi_gui.cc:4104
IMPORT W array_x(W *arr, int size, int x_gap)
Definition GameApi_gui.cc:6129
IMPORT W shaderapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8986
IMPORT W shader_dialog(SFO p, W &close_button, FtA atlas, BM atlas_bm, int screen_size_x, int screen_size_y, W &codegen_button, W &collect_button)
Definition GameApi_gui.cc:5322
IMPORT W margin(W item, int left, int top, int right, int bottom)
Definition GameApi_gui.cc:6113
IMPORT W asset_item(EveryApi &ev, std::string jpg_url, std::string jpg_display_name, FtA atlas, BM atlas_bm)
Definition GameApi_gui.cc:4177
IMPORT std::string floatbitmapapi_functions_item_label(int i)
Definition GameApi_gui.cc:8805
IMPORT W text(std::string label, FtA atlas, BM atlas_bm, int x_gap=3)
Definition GameApi_gui.cc:4658
IMPORT W center_y(W item, int sy)
Definition GameApi_gui.cc:5808
IMPORT W edit_dialog(const std::vector< std::string > &labels, const std::vector< EditTypes * > &vec, Ft font, const std::vector< std::string > &types, W &cancel_button, W &ok_button)
IMPORT int canvas_item(W canvas, W item, int x, int y)
Definition GameApi_gui.cc:3776
IMPORT void set_size(W ow, float sx, float sy)
Definition GameApi_gui.cc:6863
IMPORT W license_dialog(std::vector< std::string > filename, std::vector< std::string > &license_url, std::vector< std::string > &author_names, FtA atlas, BM atlas_bm, FtA atlas2, BM atlas_bm2, FtA atlas3, BM atlas_bm3, W &next_button, W &cancel_button, W &canvas2, W &canvas_area, W &scroll_bar)
Definition GameApi_gui.cc:4256
IMPORT W window_decoration2(int sx, int sy, std::string label, FtA atlas, BM atlas_bm, bool move)
Definition GameApi_gui.cc:5371
IMPORT W button(int sx, int sy, unsigned int color_1, unsigned int color_2)
Definition GameApi_gui.cc:6650
IMPORT W asset_dialog(EveryApi &ev, std::vector< std::string > jpg_urls, std::vector< std::string > jpg_display_names, W &select_button, W &cancel_button, FtA atlas, BM atlas_bm)
Definition GameApi_gui.cc:4192
IMPORT W hide_if_array_empty(W w, std::vector< W > items, W *redraw_w)
Definition GameApi_gui.cc:4612
IMPORT W bitmap_dialog(BM bm, W &close_button, FtA atlas, BM atlas_bm, W &codegen_button, W &collect_button, FtA atlas_tiny, BM atlas_tiny_bm)
Definition GameApi_gui.cc:5526
IMPORT void delete_widget(W w)
Definition GameApi_gui.cc:9075
IMPORT W canvas_item_gameapi_node(int sx, int sy, std::string label, std::vector< std::string > param_types, std::vector< std::string > param_tooltips, std::string return_type, FtA atlas, BM atlas_bm, std::vector< W * > connect_click, std::string uid, std::vector< W > ¶ms, std::string symbol, std::string comment)
Definition GameApi_gui.cc:4454
IMPORT std::string floatvolumeapi_functions_item_label(int i)
Definition GameApi_gui.cc:8781
IMPORT W center_align(W item, int sx)
Definition GameApi_gui.cc:5803
IMPORT W poly(P p, SH sh, int sx, int sy, int screen_size_x, int screen_size_y)
Definition GameApi_gui.cc:4695
IMPORT W menu(W main_menu, int menu_id, std::vector< std::string > labels, FtA atlas, BM atlas_bm)
Definition GameApi_gui.cc:6760
IMPORT void set_id(W w, std::string id)
Definition GameApi_gui.cc:6972
IMPORT W icon(BM bitmap)
Definition GameApi_gui.cc:4670
IMPORT std::string waveformapi_functions_item_label(int i)
Definition GameApi_gui.cc:8693
IMPORT W pointsapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8998
IMPORT W get_child(W w, int i)
Definition GameApi_gui.cc:6914
IMPORT W key_area(W widget, int area_x, int area_y, int area_width, int area_height, int key)
Definition GameApi_gui.cc:4097
IMPORT W click_area(W widget, int area_x, int area_y, int area_width, int area_height, int button_id)
Definition GameApi_gui.cc:4091
IMPORT W layout_rb(W item, int left, int top, int width, int height, int right, int bottom, int(*fptr_r)(void *), int(*fptr_b)(void *), void *ctx1, void *ctx2)
Definition GameApi_gui.cc:6095
IMPORT W textureapi_functions_list_item(FtA font1, BM font1_bm, FtA font2, BM font2_bm, W insert, W *outer)
Definition GameApi_gui.cc:8946
IMPORT std::string polygondistapi_functions_item_label(int i)
Definition GameApi_gui.cc:8767
IMPORT std::string moveapi_functions_item_label(int i)
Definition GameApi_gui.cc:8834
IMPORT W empty()
Definition GameApi_gui.cc:3682
IMPORT void generic_to_string(const EditTypes &source, std::string type, std::string &target, std::string &expr)
Definition GameApi_gui.cc:5890
IMPORT W float_editor(float &target, std::string &target_expr, FtA atlas, BM atlas_bm, int x_gap, int noneditnum=0)
Definition GameApi_gui.cc:4748
IMPORT W highlight(int sx, int sy)
Definition GameApi_gui.cc:6071
IMPORT std::string shadermoduleapi_functions_item_label(int i)
Definition GameApi_gui.cc:8724
IMPORT void string_to_generic(EditTypes &target, std::string type, const std::string &source, const std::string &expr)
Definition GameApi_gui.cc:5824
IMPORT W color_editor(std::string &col, FtA atlas, BM atlas_bm, int x_gap, int noneditnum, std::string &expr)
Definition GameApi_gui.cc:4951
IMPORT W layout_lt(W item, int left, int top, int width, int height, int right, int bottom, int(*fptr_l)(void *), int(*fptr_t)(void *), void *ctx1, void *ctx2)
Definition GameApi_gui.cc:6085
IMPORT W find_canvas_item(W canvas, std::string id)
Definition GameApi_gui.cc:3739
IMPORT W string_editor(std::string allowed_chars, std::string &target, std::string &target_expr, FtA atlas, BM atlas_bm, int x_gap, int non_editable, W *redraw_w, bool allow_expr=true)
Definition GameApi_gui.cc:4731
IMPORT W left_align(W item, int sx)
Definition GameApi_gui.cc:5798
IMPORT int chosen_item(W w)
Definition GameApi_gui.cc:6886
IMPORT W url_editor(std::string &target, FtA atlas, BM atlas_bm, int x_gap, std::string &expr, int noneditnum=0)
Definition GameApi_gui.cc:4759
IMPORT W ml_dialog(ML p, SH sh, SH sh2, SH sh_2d, SH sh_arr, int screen_size_x, int screen_size_y, W &close_button, FtA atlas, BM atlas_bm, W &codegen_button, W &collect_button)
Definition GameApi_gui.cc:5275
IMPORT W enum_editor(EveryApi &ev, W &click_target, int &target, FtA atlas, BM atlas_bm, int x_gap, std::string type, std::string &expr, int noneditnum=0)
Definition GameApi_gui.cc:4793
IMPORT void del_canvas_item(W canvas, int id)
Definition GameApi_gui.cc:3789
IMPORT ML async_url(std::string url, ML ml)
Definition GameApi_gui.cc:7922
Definition GraphI.hh:1615
virtual void Collect(CollectVisitor &vis)=0
virtual std::vector< int > shader_id()
Definition GraphI.hh:1625
virtual void handle_event(MainLoopEvent &e)=0
virtual void execute(MainLoopEnv &e)=0
static Matrix Scale(float x, float y, float z)
Definition VectorTools.cc:556
Definition GameApi_gui.cc:332
MousePositionTweakForEditors(GameApi::EveryApi &ev, GuiWidget *inner, GuiWidget *outer, GuiWidget *outerouter)
Definition GameApi_gui.cc:334
int chosen_item() const
Definition GameApi_gui.cc:376
Point2d get_mouse_tweak(Point2d p, bool &done)
Definition GameApi_gui.cc:352
virtual Vector2d get_size() const
Definition GameApi_gui.cc:375
virtual Point2d get_pos() const
Definition GameApi_gui.cc:374
void render()
Definition GameApi_gui.cc:377
void set_pos(Point2d pos)
Definition GameApi_gui.cc:340
void update(Point2d mouse, int button, int ch, int type, int mouse_wheel_y)
Definition GameApi_gui.cc:364
void set_size(Vector2d size_p)
Definition GameApi_gui.cc:346
int render_to_bitmap()
Definition GameApi_gui.cc:381
Definition GameApi_gui.cc:947
void update(Point2d mouse, int button, int ch, int type, int mouse_wheel_y)
Definition GameApi_gui.cc:957
void render()
Definition GameApi_gui.cc:1039
MultilineEditor(GameApi::EveryApi &ev, std::string allowed_chars, T &target_m, GameApi::FI font, GameApi::SH sh, int x_gap, int line_height)
Definition GameApi_gui.cc:949
Definition GameApi_low.hh:299
virtual void glEnable(int val)=0
virtual void glViewport(int x, int y, unsigned int w, unsigned int h)=0
virtual void glDisable(int val)=0
virtual void glScissor(float x, float y, float w, float h)=0
@ EDragDropInfoMessage
Definition test.cpp:180
virtual Low_SDL_Joystick * SDL_JoystickOpen(int i)=0
virtual unsigned int SDL_JoystickGetButton(Low_SDL_Joystick *joy, int i)=0
Definition GameApi_gui.cc:726
TextGuiWidgetAtlas(GameApi::EveryApi &ev, std::string label, GameApi::FtA atlas, GameApi::BM atlas_bm, GameApi::SH sh, int x_gap)
Definition GameApi_gui.cc:728
int render_to_bitmap()
Definition GameApi_gui.cc:791
void update(Point2d mouse, int button, int ch, int type, int mouse_wheel_y)
Definition GameApi_gui.cc:736
void render()
Definition GameApi_gui.cc:776
IMPORT int g_event_screen_y
Definition GameApi.cc:18167
IMPORT Low_SDL_Window * sdl_window
Definition GameApi.cc:38469
IMPORT bool g_transparent
Definition GameApi_gui.cc:1693
IMPORT int g_event_screen_x
Definition GameApi.cc:18166
int find_str(std::string val, std::string repl)
Definition GameApi.cc:26716
IMPORT GameApi::PAT gameapi_temp_dir
Definition test.cpp:4591
bool g_dragdrop_enabled
Definition GameApi_gui.cc:1067
IMPORT void enum_set_value(GameApi::Env &e, GameApi::W enum_click, int value)
Definition GameApi_gui.cc:4889
W functions_widget(GameApi::GuiApi &gui, std::string label, std::vector< GameApiItem * > vec, GameApi::FtA atlas, GameApi::BM atlas_bm, GameApi::FtA atlas2, GameApi::BM atlas_bm2, GameApi::W insert)
IMPORT PathHandler * g_path_handler
Definition GameApi_dep_env.cc:6102
GameApi::W enum_click
Definition GameApi_gui.cc:4828
int async_pending_count
Definition GameApi.cc:18142
ASyncData * g_async_ptr2
Definition GameApi_gui.cc:7817
std::vector< std::string > g_registered_urls
Definition GameApi_gui.cc:7899
std::string g_dragdrop_filename
Definition GameApi_gui.cc:1068
IMPORT ArrayType * find_array(GameApi::Env &e, GameApi::ARR arr)
Definition GameApi_dep_add_find.cc:1924
int g_window_pos_y
Definition GameApi_gui.cc:3869
IMPORT void ProgressBar(int num, int val, int max, std::string label)
Definition GameApi_dep_env.cc:4198
void save_mod_txt_from_script_file2(GameApi::EveryApi &ev, std::string input_script_filename, std::string output_mod_txt_filename)
Definition GameApi_gui.cc:7610
IMPORT void InstallProgress(int num, std::string label, int max=15)
Definition GameApi_dep_env.cc:3971
int g_window_pos_x
Definition GameApi_gui.cc:3868
const char * g_videodriver
Definition Main.cc:2092
IMPORT void enum_editor_handle_event(GameApi::GuiApi &gui, std::vector< GameApi::W > vec, int button)
Definition GameApi_gui.cc:4870
GameApi::GuiApi * g_everyapi_gui
Definition GameApi_dep_env.cc:4174
GameApi::W enum_popup
Definition GameApi_gui.cc:4827
IMPORT bool file_exists(std::string s)
Definition GameApi_dep_env.cc:4387
std::vector< GameApiItem * > global_functions
Definition GameApi_gui.cc:8637
int g_async_count2
Definition GameApi_gui.cc:7818
IMPORT bool g_reload_edit_dialog
Definition test.cpp:79
IMPORT bool enum_editor_callback(GameApi::Env &env, GameApi::GuiApi &gui, GameApi::W click_widget, std::string type, int mouse_x, int mouse_y, GameApi::FtA atlas, GameApi::BM atlas_bm, int x_gap, std::vector< GameApi::W > &areas, int button, int type2)
Definition GameApi_gui.cc:4829
void update_progress_dialog_cb_impl(volatile GameApi::W &w, int x, int y, GameApi::FtA f, GameApi::BM b, std::vector< std::string >, int val, int max, int process)
Definition GameApi_gui.cc:4432
IMPORT void enum_editor_draw(GameApi::EveryApi &ev, GameApi::GuiApi &gui)
Definition GameApi_gui.cc:4864
let delta_y
Definition gameapi_example.php:63
let delta_x
Definition gameapi_example.php:62
background color
Definition gameapi_example.php:46
PT func2(int face, int point, EveryApi &ev)
Definition test.cpp:27
exit
Definition mesh_ai_bm.php:3
left margin
Definition mesh_preview.php:76
d
Definition meshpage.php:3895
iVBORw0KGgoAAAANSUhEUgAAANcAAAB5CAMAAACdtUQZAAAA51BMVEX</div ></div >< div style="padding: 0px 0px; width: 1324px;">< div style="height: 400px; width: 1324px;"></div >< div itemscope itemtype="https: </div><div itemscope itemtype="https:</div >< div itemscope itemtype="https: </div></div><p><div style="padding:0px 0px;width:1324px;"><div></div><div itemscope itemtype="https:< ul >< li >< b > Application name
8AkrcAgqgAs9wqQ0ey2tkAo8gAuuQfeI4hPUH09fXHy8z4+fng4uNKXF/Lz9BzfoAcgpkQMTUAKjAbOT4Qr9AXhJ8Rl7ktMCwTosA...
Definition meshpage.php:1610
lazy data
Definition meshpage.php:1583
str
Definition meshpage.php:1778
n< br > font size
Definition meshpage.php:3536
url
Definition meshpage.php:1781
Numeric sum(Range c)
Returns the sum total of the values in the Range c.
int collect_counter(int mode)
IMPORT std::pair< int, std::string > execute_codegen(Env &e2, EveryApi &ev, std::string text, ExecuteEnv &e)
Definition GameApi_gui.cc:8557
size_t count(const T &t_target, const typename T::key_type &t_key)
Definition bootstrap_stl.hpp:104
void insert(T &t_target, const T &t_other)
Definition bootstrap_stl.hpp:110
auto child_count(const eval::AST_Node_Impl< T > &node)
Definition chaiscript_optimizer.hpp:60
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition json.hpp:1781
double f(const std::string &, double, bool) noexcept
Definition profile_cpp_calls_2.cpp:4
Definition GameApi_dep_env.cc:2495
void(* fptr)(void *)
Definition GameApi_dep_env.cc:2495
void * data
Definition GameApi_dep_env.cc:2495
std::vector< int > vec
Definition test.cpp:84
Definition GameApi_cmd.hh:41
Definition GameApi_h.hh:672
::EnvImpl * Environment(GameApi::Env *e)
Definition GameApi_h.hh:848
Definition GameApi_h.hh:615
int sy
Definition GameApi_h.hh:616
int y
Definition GameApi_h.hh:618
int top
Definition GameApi_h.hh:619
Definition GameApi_h.hh:626
Definition GraphI.hh:1409
std::vector< std::string > param_names
Definition GraphI.hh:1411
std::string function_name
Definition GraphI.hh:1410
std::vector< std::string > param_types
Definition GraphI.hh:1412
std::vector< GameApiLine > lines
Definition GraphI.hh:1413
std::string uid
Definition GraphI.hh:1401
std::vector< GameApiParam > params
Definition GraphI.hh:1405
int y
Definition GraphI.hh:1399
int x
Definition GraphI.hh:1399
std::string module_name
Definition GraphI.hh:1400
int sz
Definition GraphI.hh:1403
int j
Definition GraphI.hh:1402
bool array_return
Definition GraphI.hh:1404
Definition GraphI.hh:1417
std::vector< GameApiFunction > funcs
Definition GraphI.hh:1418
std::string param_name
Definition test.cpp:368
bool is_array
Definition test.cpp:370
GameApiLine * array_return_target
Definition test.cpp:371
std::string value
Definition test.cpp:369
int j
Definition GraphI.hh:1346
int id
Definition GameApi.hh:112
int id
Definition Common.hh:71
Definition GameApi.hh:4664
Definition GameApi.hh:301
Definition GameApi.hh:2373
float f_value
Definition GameApi.hh:2376
std::string s
Definition GameApi.hh:2379
int i_value
Definition GameApi.hh:2374
float f_z
Definition GameApi.hh:2377
float f_x
Definition GameApi.hh:2377
std::string color
Definition GameApi.hh:2378
float f_y
Definition GameApi.hh:2377
std::string expr
Definition GameApi.hh:2380
long l_value
Definition GameApi.hh:2375
int id
Definition Common.hh:153
std::string url
Definition GameApi_dep_env.cc:3025
std::string url3
Definition GameApi_dep_env.cc:3026
char * buf3
Definition GameApi_dep_env.cc:3028
char * buf2
Definition GameApi_dep_env.cc:3027
OpenglLowApi * ogl
Definition GameApi_low.hh:814
SDLLowApi * sdl
Definition GameApi_low.hh:819
Definition GameApi_low.hh:680
Definition VectorTools.hh:910
float x
Definition VectorTools.hh:911
float y
Definition VectorTools.hh:911
float x
Definition Parser.cc:60
float y
Definition Parser.cc:60
float z
Definition Parser.cc:60
int id
Definition GameApi.h:42
Definition VectorTools.hh:972
float dy
Definition VectorTools.hh:973
float dx
Definition VectorTools.hh:973
int to_int(TestEnum t)
Definition test_module.cpp:73
W link(std::string url, std::string str, int size_x, int size_y, int font_size, unsigned int font_colour, int align)
Definition ui.cc:731
W empty()
Definition ui.cc:634
W center_y(W item, int sy)
Definition ui.cc:947
W editor(std::string name, std::string value, std::string placeholder, int size_x, int size_y, int font_size, unsigned int font_colour, int align)
Definition ui.cc:1148
W layer(std::vector< W > v)
Definition ui.cc:737
W right_align(W item, int sx)
Definition ui.cc:935
W center_align(W item, int sx)
Definition ui.cc:941
W hide(W widget)
Definition ui.cc:954
W max_width(W w1, int width)
get_label( $arr)
Definition user.php:289
num
Definition view.php:2821
P line_func(int i, float sx, float sy, float sz, float ex, float ey, float ez, unsigned int scolor, unsigned int ecolor, EveryApi &ev)
Definition test.cpp:87