add imgui popups
This commit is contained in:
parent
a1cd43bcfd
commit
8da89f1032
|
@ -35,7 +35,7 @@ var sprite = {
|
||||||
rect: fullrect,
|
rect: fullrect,
|
||||||
anim:{},
|
anim:{},
|
||||||
playing: 0,
|
playing: 0,
|
||||||
play(str = 0) {
|
play(str = 0, fn, loop = true, reverse = false) {
|
||||||
this.del_anim?.();
|
this.del_anim?.();
|
||||||
var self = this;
|
var self = this;
|
||||||
var stop;
|
var stop;
|
||||||
|
@ -48,6 +48,9 @@ var sprite = {
|
||||||
var playing = self.anim[str];
|
var playing = self.anim[str];
|
||||||
if (!playing) return;
|
if (!playing) return;
|
||||||
var f = 0;
|
var f = 0;
|
||||||
|
if (reverse)
|
||||||
|
f = playing.frames.length-1;
|
||||||
|
|
||||||
self.path = playing.path;
|
self.path = playing.path;
|
||||||
|
|
||||||
function advance() {
|
function advance() {
|
||||||
|
@ -56,10 +59,21 @@ var sprite = {
|
||||||
self.frame = playing.frames[f].rect;
|
self.frame = playing.frames[f].rect;
|
||||||
self.rect = [self.frame.x, self.frame.y, self.frame.w, self.frame.h];
|
self.rect = [self.frame.x, self.frame.y, self.frame.w, self.frame.h];
|
||||||
self.update_dimensions();
|
self.update_dimensions();
|
||||||
|
var done = false;
|
||||||
|
if (reverse) {
|
||||||
|
f = (((f-1)%playing.frames.length)+playing.frames.length)%playing.frames.length;
|
||||||
|
if (f === playing.frames.length-1) done = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
f = (f+1)%playing.frames.length;
|
f = (f+1)%playing.frames.length;
|
||||||
if (f === 0) {
|
if (f === 0) done = true;
|
||||||
self.anim_done?.();
|
}
|
||||||
if (!self.loop) { self.stop(); return; }
|
|
||||||
|
if (done) {
|
||||||
|
fn?.();
|
||||||
|
if (!loop) { self?.stop(); return; }
|
||||||
|
// self?.anim_done?.();
|
||||||
|
// if (!self.loop) { self.stop(); return; }
|
||||||
}
|
}
|
||||||
stop = self.gameobject.delay(advance, playing.frames[f].time);
|
stop = self.gameobject.delay(advance, playing.frames[f].time);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,10 @@ var entity = {
|
||||||
|
|
||||||
function update(dt) {
|
function update(dt) {
|
||||||
profile.frame("timer");
|
profile.frame("timer");
|
||||||
|
if (stop) { // TODO: This seems broken
|
||||||
stop.remain -= dt;
|
stop.remain -= dt;
|
||||||
if (stop.remain <= 0) execute();
|
if (stop.remain <= 0) execute();
|
||||||
|
}
|
||||||
profile.endframe();
|
profile.endframe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,45 @@ JSC_SCALL(imgui_int,
|
||||||
ret = number2js(n);
|
ret = number2js(n);
|
||||||
)
|
)
|
||||||
|
|
||||||
|
JSC_SCALL(imgui_open_popup,
|
||||||
|
ImGui::OpenPopup(str);
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_SCALL(imgui_popup,
|
||||||
|
if (ImGui::BeginPopup(str)) {
|
||||||
|
script_call_sym(argv[1],0,NULL);
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_CCALL(imgui_close_popup,
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_SCALL(imgui_modal,
|
||||||
|
if (ImGui::BeginPopupModal(str)) {
|
||||||
|
script_call_sym(argv[1],0,NULL);
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_SCALL(imgui_context,
|
||||||
|
if (ImGui::BeginPopupContextItem(str)) {
|
||||||
|
script_call_sym(argv[1],0,NULL);
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_SCALL(imgui_table,
|
||||||
|
if (ImGui::BeginTable(str, js2number(argv[1]))) {
|
||||||
|
script_call_sym(argv[2],0,NULL);
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_CCALL(imgui_tablenextrow, ImGui::TableNextRow())
|
||||||
|
JSC_CCALL(imgui_tablenextcolumn, ImGui::TableNextColumn())
|
||||||
|
|
||||||
static const JSCFunctionListEntry js_imgui_funcs[] = {
|
static const JSCFunctionListEntry js_imgui_funcs[] = {
|
||||||
MIST_FUNC_DEF(imgui, window, 2),
|
MIST_FUNC_DEF(imgui, window, 2),
|
||||||
MIST_FUNC_DEF(imgui, menu, 2),
|
MIST_FUNC_DEF(imgui, menu, 2),
|
||||||
|
@ -235,6 +274,14 @@ static const JSCFunctionListEntry js_imgui_funcs[] = {
|
||||||
MIST_FUNC_DEF(imgui, listbox, 3),
|
MIST_FUNC_DEF(imgui, listbox, 3),
|
||||||
MIST_FUNC_DEF(imgui, tabbar, 2),
|
MIST_FUNC_DEF(imgui, tabbar, 2),
|
||||||
MIST_FUNC_DEF(imgui, tab, 2),
|
MIST_FUNC_DEF(imgui, tab, 2),
|
||||||
|
MIST_FUNC_DEF(imgui, open_popup, 1),
|
||||||
|
MIST_FUNC_DEF(imgui, modal, 2),
|
||||||
|
MIST_FUNC_DEF(imgui, popup, 2),
|
||||||
|
MIST_FUNC_DEF(imgui, close_popup,0),
|
||||||
|
MIST_FUNC_DEF(imgui, context,2),
|
||||||
|
MIST_FUNC_DEF(imgui, table, 3),
|
||||||
|
MIST_FUNC_DEF(imgui, tablenextcolumn,0),
|
||||||
|
MIST_FUNC_DEF(imgui, tablenextrow,0),
|
||||||
};
|
};
|
||||||
|
|
||||||
static int started = 0;
|
static int started = 0;
|
||||||
|
|
Loading…
Reference in a new issue