Add simple macos window cmds; add moon.gif app icon; add editor mode for low power editing
This commit is contained in:
parent
27aaa8e05d
commit
24a3ee20c6
2
Makefile
2
Makefile
|
@ -210,7 +210,7 @@ jso: tools/jso.c $(BIN)/libquickjs.a
|
|||
clean:
|
||||
@echo Cleaning project
|
||||
@rm -rf bin dist
|
||||
@rm -f shaders/*.sglsl.h shaders/*.metal core.cdb jso cdb packer TAGS
|
||||
@rm -f shaders/*.sglsl.h shaders/*.metal core.cdb jso cdb packer TAGS scripts/*.jso
|
||||
@make -C $(CDB) clean
|
||||
@make -C quickjs clean
|
||||
|
||||
|
|
BIN
icons/moon.gif
Normal file
BIN
icons/moon.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -97,7 +97,7 @@ var Debug = {
|
|||
|
||||
if (this.draw_names)
|
||||
Game.objects.forEach(function(x) {
|
||||
GUI.text(x.fullpath(), world2screen(x.pos).add([0,32]), 1, [84,110,255]);
|
||||
GUI.text(x, world2screen(x.pos).add([0,32]), 1, [84,110,255]);
|
||||
});
|
||||
|
||||
if (Debug.Options.gif.rec) {
|
||||
|
|
44
source/engine/thirdparty/sokol/sokol_app.h
vendored
44
source/engine/thirdparty/sokol/sokol_app.h
vendored
|
@ -3437,6 +3437,50 @@ _SOKOL_PRIVATE void _sapp_macos_run(const sapp_desc* desc) {
|
|||
// set the application dock icon as early as possible, otherwise
|
||||
// the dummy icon will be visible for a short time
|
||||
sapp_set_icon(&_sapp.desc.icon);
|
||||
|
||||
NSMenu* menu_bar = [[NSMenu alloc] init];
|
||||
NSMenuItem* app_menu_item = [[NSMenuItem alloc] init];
|
||||
[menu_bar addItem:app_menu_item];
|
||||
NSApp.mainMenu = menu_bar;
|
||||
NSMenu* app_menu = [[NSMenu alloc] init];
|
||||
NSString* window_title_as_nsstring = [NSString stringWithUTF8String:desc->window_title];
|
||||
|
||||
NSString* quit_title = [@"Quit " stringByAppendingString:window_title_as_nsstring];
|
||||
NSMenuItem* quit_menu_item = [[NSMenuItem alloc]
|
||||
initWithTitle:quit_title
|
||||
action:@selector(terminate:)
|
||||
keyEquivalent:@"q"];
|
||||
|
||||
NSString* hide_title = [@"Hide " stringByAppendingString:window_title_as_nsstring];
|
||||
NSMenuItem* hide_menu_item = [[NSMenuItem alloc]
|
||||
initWithTitle:hide_title
|
||||
action:@selector(hide:)
|
||||
keyEquivalent:@"h"];
|
||||
|
||||
NSMenuItem* hide_others_item = [[NSMenuItem alloc]
|
||||
initWithTitle:@"Hide Others"
|
||||
action:@selector(hideOtherApplications:)
|
||||
keyEquivalent:@"h"];
|
||||
|
||||
[hide_others_item setKeyEquivalentModifierMask: NSEventModifierFlagOption];
|
||||
|
||||
NSMenuItem* show_all_item = [[NSMenuItem alloc]
|
||||
initWithTitle:@"Show All"
|
||||
action:@selector(unhideAllApplications:)
|
||||
keyEquivalent:@""];
|
||||
|
||||
[app_menu addItem:hide_menu_item];
|
||||
[app_menu addItem:hide_others_item];
|
||||
[app_menu addItem:show_all_item];
|
||||
[app_menu addItem:[NSMenuItem separatorItem]];
|
||||
[app_menu addItem:quit_menu_item];
|
||||
app_menu_item.submenu = app_menu;
|
||||
|
||||
_SAPP_OBJC_RELEASE(window_title_as_nsstring);
|
||||
_SAPP_OBJC_RELEASE(app_menu);
|
||||
_SAPP_OBJC_RELEASE(app_menu_item);
|
||||
_SAPP_OBJC_RELEASE(menu_bar);
|
||||
|
||||
_sapp.macos.app_dlg = [[_sapp_macos_app_delegate alloc] init];
|
||||
NSApp.delegate = _sapp.macos.app_dlg;
|
||||
|
||||
|
|
|
@ -83,12 +83,13 @@ void window_seticon(struct window *w, struct Texture *tex)
|
|||
int size;
|
||||
unsigned char *data;
|
||||
};
|
||||
struct isize sizes[3];
|
||||
struct isize sizes[4];
|
||||
sizes[0].size = 16;
|
||||
sizes[1].size = 32;
|
||||
sizes[2].size = 64;
|
||||
sizes[3].size = 128;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
sizes[i].data = malloc(4*sizes[i].size*sizes[i].size);
|
||||
stbir_resize_uint8(tex->data, tex->width, tex->height, 0, sizes[i].data, sizes[i].size, sizes[i].size, 0, 4);
|
||||
}
|
||||
|
@ -97,12 +98,13 @@ void window_seticon(struct window *w, struct Texture *tex)
|
|||
.images = {
|
||||
{ .width = sizes[0].size, .height = sizes[0].size, .pixels = { .ptr=sizes[0].data, .size=4*sizes[0].size*sizes[0].size } },
|
||||
{ .width = sizes[1].size, .height = sizes[1].size, .pixels = { .ptr=sizes[1].data, .size=4*sizes[1].size*sizes[1].size } },
|
||||
{ .width = sizes[2].size, .height = sizes[2].size, .pixels = { .ptr=sizes[2].data, .size=4*sizes[2].size*sizes[2].size } },
|
||||
{ .width = sizes[2].size, .height = sizes[2].size, .pixels = { .ptr=sizes[2].data, .size=4*sizes[2].size*sizes[2].size } },
|
||||
{ .width = sizes[3].size, .height = sizes[3].size, .pixels = { .ptr=sizes[3].data, .size=4*sizes[3].size*sizes[3].size } },
|
||||
}
|
||||
};
|
||||
|
||||
sapp_set_icon(&idsc);
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
free(sizes[i].data);
|
||||
}
|
||||
|
||||
|
|
|
@ -133,6 +133,7 @@ static char **args;
|
|||
|
||||
void c_init() {
|
||||
render_init();
|
||||
window_set_icon("icons/moon.gif");
|
||||
window_resize(sapp_width(), sapp_height());
|
||||
script_evalf("initialize();");
|
||||
}
|
||||
|
@ -141,14 +142,10 @@ int frame_fps() {
|
|||
return 1.0/sapp_frame_duration();
|
||||
}
|
||||
|
||||
static double low_fps = 1/24.0;
|
||||
static double low_fps_c = 0.0;
|
||||
|
||||
void c_frame()
|
||||
static void process_frame()
|
||||
{
|
||||
double elapsed = sapp_frame_duration();
|
||||
appTime += elapsed;
|
||||
low_fps_c += elapsed;
|
||||
|
||||
input_poll(0);
|
||||
timer_update(elapsed, timescale);
|
||||
|
@ -175,10 +172,9 @@ void c_frame()
|
|||
sim_pause();
|
||||
render_dirty = 1;
|
||||
}
|
||||
low_fps_c = 0.0f;
|
||||
}
|
||||
|
||||
if (sim_play == SIM_PLAY || render_dirty || low_fps_c >= low_fps) {
|
||||
if (sim_play == SIM_PLAY || render_dirty) {
|
||||
prof_start(&prof_draw);
|
||||
window_render(&mainwin);
|
||||
prof(&prof_draw);
|
||||
|
@ -188,6 +184,12 @@ void c_frame()
|
|||
gameobjects_cleanup();
|
||||
}
|
||||
|
||||
void c_frame()
|
||||
{
|
||||
if (sim_play != SIM_PLAY) return;
|
||||
process_frame();
|
||||
}
|
||||
|
||||
void c_clean() {
|
||||
gif_rec_end("out.gif");
|
||||
};
|
||||
|
@ -257,6 +259,9 @@ void c_event(const sapp_event *e)
|
|||
window_quit();
|
||||
break;
|
||||
}
|
||||
|
||||
if (sim_play != SIM_PLAY)
|
||||
process_frame();
|
||||
}
|
||||
|
||||
int sim_playing() { return sim_play == SIM_PLAY; }
|
||||
|
@ -370,5 +375,6 @@ sapp_desc sokol_main(int argc, char **argv) {
|
|||
start_desc.height = mainwin.height;
|
||||
start_desc.fullscreen = 0;
|
||||
|
||||
|
||||
return start_desc;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue