Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions editor/editor_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,6 @@ draw_editor(window_t *win,
glBindBuffer(GL_ARRAY_BUFFER, editor->vbo);
glDisable(GL_DEPTH_TEST);

extern window_t *_focused;

// if (editor->window != active) {
// goto draw_player;
// }
Expand Down
35 changes: 17 additions & 18 deletions editor/editor_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,13 @@ void set_selection_mode(editor_state_t *editor, int mode) {
return;
}
clear_window_children(g_inspector);
send_message(g_inspector, kWindowMessageCreate, 0, editor);
send_message(g_inspector, evCreate, 0, editor);
invalidate_window(g_inspector);
}

static void update_inspector(editor_state_t *editor, objtype_t type) {
extern window_t *_focused;
winproc_t proc = NULL;
window_t *old_focus = _focused;
window_t *old_focus = g_ui_runtime.focused;
switch (type) {
case ObjTypeThing: proc = win_thing; break;
case ObjTypeSector: proc = win_sector; break;
Expand All @@ -128,7 +127,7 @@ static void update_inspector(editor_state_t *editor, objtype_t type) {
if (g_inspector->proc != proc) {
g_inspector->proc = proc;
clear_window_children(g_inspector);
send_message(g_inspector, kWindowMessageCreate, 0, editor);
send_message(g_inspector, evCreate, 0, editor);
invalidate_window(g_inspector);
set_focus(old_focus);
}
Expand Down Expand Up @@ -219,17 +218,17 @@ result_t win_editor(window_t *win, uint32_t msg, uint32_t wparam, void *lparam)
editor_state_t *editor = game ? &game->state : NULL;
int point = -1;
switch (msg) {
case kWindowMessageCreate:
case evCreate:
win->userdata = lparam;
((game_t *)lparam)->state.window = win;
return true;
case kWindowMessageDestroy:
case evDestroy:
free_map_data(&game->map);
return true;
case kWindowMessagePaint:
case evPaint:
draw_editor(win, &game->map, editor, &game->player);
return true;
case kWindowMessageMouseMove:
case evMouseMove:
track_mouse(win);
editor->hover.type = ObjTypeNone;
editor->hover.index = 0xFFFF;
Expand Down Expand Up @@ -279,19 +278,19 @@ result_t win_editor(window_t *win, uint32_t msg, uint32_t wparam, void *lparam)
invalidate_window(win);
invalidate_window(g_inspector);
return true;
// case kWindowMessageWheel:
// case evWheel:
// editor->scale *= 1.f - (int16_t)HIWORD(wparam)/50.f;
// invalidate_window(win);
// return true;
case kWindowMessageMouseLeave:
case evMouseLeave:
// editor->hover.point = -1;
// editor->hover.sector = -1;
// editor->hover.line = -1;
// editor->hover.thing = -1;
invalidate_window(win);
invalidate_window(g_inspector);
return true;
case kWindowMessageWheel: {
case evWheel: {
mat4 mvp;
vec3 world_before, world_after, delta;
get_editor_mvp(editor, mvp);
Expand All @@ -304,7 +303,7 @@ result_t win_editor(window_t *win, uint32_t msg, uint32_t wparam, void *lparam)
invalidate_window(win);
return true;
}
case kWindowMessageLeftButtonUp:
case evLeftButtonUp:
if (editor->move_camera == 2) {
editor->move_camera = 1;
} else if (editor->sel_mode == EditModeSelect) {
Expand All @@ -314,7 +313,7 @@ result_t win_editor(window_t *win, uint32_t msg, uint32_t wparam, void *lparam)
// editor->move_thing = 0;
}
return true;
case kWindowMessageLeftButtonDown:
case evLeftButtonDown:
if (editor->move_camera > 0) {
editor->move_camera = 2;
return true;
Expand Down Expand Up @@ -385,7 +384,7 @@ result_t win_editor(window_t *win, uint32_t msg, uint32_t wparam, void *lparam)
break;
}
return true;
case kWindowMessageRightButtonDown:
case evRightButtonDown:
switch (editor->sel_mode) {
case EditModeVertices:
if (editor->drawing) {
Expand All @@ -403,7 +402,7 @@ result_t win_editor(window_t *win, uint32_t msg, uint32_t wparam, void *lparam)
break;
}
return true;
case kWindowMessageRightButtonUp:
case evRightButtonUp:
switch (editor->sel_mode) {
case EditModeVertices:
if (editor->dragging && has_selection(editor->hover, ObjTypePoint)) {
Expand All @@ -417,10 +416,10 @@ result_t win_editor(window_t *win, uint32_t msg, uint32_t wparam, void *lparam)
return true;
}
return true;
case kWindowMessageKillFocus:
case evKillFocus:
editor_reset_input(editor);
return true;
case kWindowMessageKeyDown:
case evKeyDown:
switch (wparam) {
case AX_KEY_W:
case AX_KEY_UPARROW:
Expand Down Expand Up @@ -479,7 +478,7 @@ result_t win_editor(window_t *win, uint32_t msg, uint32_t wparam, void *lparam)
return true;
}
break;
case kWindowMessageKeyUp:
case evKeyUp:
if (wparam == AX_KEY_CTRL) {
editor->move_camera = 0;
}
Expand Down
48 changes: 24 additions & 24 deletions editor/windows/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <mapview/sprites.h>
#include <mapview/console.h>
#include <editor/editor.h>
#include <ui/user/user.h>
#include <ui/user/draw.h>

game_t *g_game = NULL;

Expand Down Expand Up @@ -50,7 +52,7 @@ void new_map(void) {
game_t *gm = malloc(sizeof(game_t));
memset(gm, 0, sizeof(game_t));
gm->last_time = (uint32_t)axGetMilliseconds();
show_window(create_window("New map", 0, new_frame(), NULL, win_editor, gm), true);
show_window(create_window("New map", 0, new_frame(), NULL, win_editor, 0, gm), true);
init_editor(&gm->state);
g_game = gm;
}
Expand Down Expand Up @@ -78,7 +80,7 @@ void open_map(const char *mapname) {

init_editor(&gm->state);

show_window(create_window(mapname, 0, new_frame(), NULL, win_editor, gm), true);
show_window(create_window(mapname, 0, new_frame(), NULL, win_editor, 0, gm), true);

g_game = gm;
}
Expand Down Expand Up @@ -204,7 +206,7 @@ void draw_dungeon(window_t const *win, bool draw_pixel) {
game_t *game = win->userdata;

if (game->map.num_vertices == 0) {
fill_rect(get_sys_color(kColorWindowBg), 0, 0, win->frame.w, win->frame.h);
fill_rect(get_sys_color(brWindowBg), R(0, 0, win->frame.w, win->frame.h));
return;
}

Expand Down Expand Up @@ -265,7 +267,7 @@ void draw_dungeon(window_t const *win, bool draw_pixel) {
set_projection(0, 0, win->frame.w, win->frame.h);

// result_t win_perf(window_t *win, uint32_t msg, uint32_t wparam, void *lparam);
// win_perf((window_t*)win, kWindowMessagePaint, 0, NULL);
// win_perf((window_t*)win, evPaint, 0, NULL);

// mapside_texture_t const *tex1 = get_texture(get_selected_texture());
// mapside_texture_t const *tex2 = get_flat_texture(get_selected_flat_texture());
Expand Down Expand Up @@ -340,33 +342,31 @@ result_t win_editor(window_t *win, uint32_t msg, uint32_t wparam, void *lparam);
result_t win_game(window_t *win, uint32_t msg, uint32_t wparam, void *lparam) {
static bool alt = false;
static bool moved = false;
extern window_t *_focused;
extern window_t *_captured;
game_t *game = win->userdata;
switch (msg) {
case kWindowMessageCreate:
case evCreate:
win->userdata = lparam;
create_window("FPS", 0, MAKERECT(0, 0, 128, 64), win, win_perf, NULL);
create_window("FPS", 0, MAKERECT(0, 0, 128, 64), win, win_perf, 0, NULL);
return true;
case kWindowMessageDestroy:
case evDestroy:
free_map_data(&game->map);
return true;
case kWindowMessagePaint:
case evPaint:
game_tick(game);
draw_dungeon(win, moved);
if (_focused == win) {
post_message(win, kWindowMessagePaint, wparam, lparam);
if (g_ui_runtime.focused == win) {
post_message(win, evPaint, wparam, lparam);
}
moved = false;
return false;
}

if (_captured == win) {
if (g_ui_runtime.captured == win) {
switch (msg) {
case kWindowMessageKillFocus:
case evKillFocus:
g_relative_mouse_mode = false;
return true;
case kWindowMessageKeyDown:
case evKeyDown:
switch (wparam) {
case AX_KEY_ESCAPE:
g_relative_mouse_mode = false;
Expand Down Expand Up @@ -419,7 +419,7 @@ result_t win_game(window_t *win, uint32_t msg, uint32_t wparam, void *lparam) {
return true;
}
return true;
case kWindowMessageKeyUp:
case evKeyUp:
switch (wparam) {
case AX_KEY_W:
case AX_KEY_UPARROW:
Expand All @@ -444,10 +444,10 @@ result_t win_game(window_t *win, uint32_t msg, uint32_t wparam, void *lparam) {
break;
}
return true;
// case kWindowMessageWheel:
// case evWheel:
// handle_scroll((int[]){(int16_t)LOWORD(wparam), (int16_t)HIWORD(wparam)}, &game->map);
// return true;
case kWindowMessageMouseMove:
case evMouseMove:
moved = true;
game->player.angle += ((int16_t)LOWORD((intptr_t)lparam)) * sensitivity_x;
game->player.pitch -= ((int16_t)HIWORD((intptr_t)lparam)) * sensitivity_y;
Expand All @@ -458,17 +458,17 @@ result_t win_game(window_t *win, uint32_t msg, uint32_t wparam, void *lparam) {
if (game->player.pitch > 89.0f) game->player.pitch = 89.0f;
if (game->player.pitch < -89.0f) game->player.pitch = -89.0f;
return true;
case kWindowMessageLeftButtonUp:
case evLeftButtonUp:
paint_face(&game->map, (ui_get_mod_state() & AX_MOD_ALT) != 0);
return true;
case kWindowMessageJoyButtonDown:
case evJoyButtonDown:
if (wparam == 0) {
paint_face(&game->map, false);
} else if (wparam == 1) {
paint_face(&game->map, true);
}
return true;
case kWindowMessageJoyAxisMotion:
case evJoyAxisMotion:
switch (LOWORD(wparam)) {
case 0: game->player.strafe_move = ((int16_t)HIWORD(wparam))/(float)0x8000; break;
case 1: game->player.forward_move = -((int16_t)HIWORD(wparam))/(float)0x8000; break;
Expand All @@ -477,15 +477,15 @@ result_t win_game(window_t *win, uint32_t msg, uint32_t wparam, void *lparam) {
}
return true;
}
} else if (_focused == win) {
} else if (g_ui_runtime.focused == win) {
switch (msg) {
case kWindowMessageLeftButtonUp:
case evLeftButtonUp:
if (!g_relative_mouse_mode) {
set_capture(win);
g_relative_mouse_mode = true;
}
return true;
case kWindowMessageKeyDown:
case evKeyDown:
switch (wparam) {
case AX_KEY_TAB:
set_capture(NULL);
Expand Down
8 changes: 4 additions & 4 deletions editor/windows/inspector/insp_line.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ result_t win_line(window_t *win, uint32_t msg, uint32_t wparam, void *lparam) {
editor_state_t *editor = get_editor();
maplinedef_t *line = selected_line(g_game);
switch (msg) {
case kWindowMessageCreate:
case evCreate:
win->userdata = lparam;
g_inspector = win;
load_window_children(win, line_layout);
return true;
case kWindowMessagePaint:
case evPaint:
if (line) {
set_window_item_text(win, ID_LINE_IDENT, "%d", line - g_game->map.linedefs);
set_window_item_text(win, ID_LINE_TYPE, "%d", line->special);
Expand Down Expand Up @@ -110,10 +110,10 @@ result_t win_line(window_t *win, uint32_t msg, uint32_t wparam, void *lparam) {
}
}
return false;
case kWindowMessageCommand:
case evCommand:
if (line) {
#define SET_OFFSET(ID, SIDE, OFFSET) \
if (wparam == MAKEDWORD(ID, kEditNotificationUpdate) && line->sidenum[SIDE] != 0xFFFF && g_game) { \
if (wparam == MAKEDWORD(ID, edUpdate) && line->sidenum[SIDE] != 0xFFFF && g_game) { \
mapsidedef_t *side = &g_game->map.sidedefs[line->sidenum[SIDE]]; \
side->OFFSET = atoi(((window_t *)lparam)->title); \
build_wall_vertex_buffer(&g_game->map); \
Expand Down
39 changes: 18 additions & 21 deletions editor/windows/inspector/insp_sector.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,27 @@ mapsector_t *selected_sector(game_t *game) {
// send_message(cb, CB_SETCURSEL, 2, NULL);
//}

static toolbar_button_t but[] = {
{ EdIcon16Select, EditModeSelect },
{ EdIcon16Points, EditModeVertices },
{ EdIcon16Things, EditModeThings },
{ EdIcon16Sounds, EditModeSounds },
static toolbar_item_t but[] = {
{ TOOLBAR_ITEM_BUTTON, EditModeSelect, EdIcon16Select, 0, 0, NULL },
{ TOOLBAR_ITEM_BUTTON, EditModeVertices, EdIcon16Points, 0, 0, NULL },
{ TOOLBAR_ITEM_BUTTON, EditModeThings, EdIcon16Things, 0, 0, NULL },
{ TOOLBAR_ITEM_BUTTON, EditModeSounds, EdIcon16Sounds, 0, 0, NULL },
};

void set_selection_mode(editor_state_t *editor, int mode);

result_t win_dummy(window_t *win, uint32_t msg, uint32_t wparam, void *lparam) {
editor_state_t *editor = get_editor();
switch (msg) {
case kWindowMessageCreate:
send_message(win, kToolBarMessageAddButtons, sizeof(but)/sizeof(*but), but);
case evCreate:
send_message(win, tbSetItems, sizeof(but)/sizeof(*but), but);
return true;
case kWindowMessagePaint:
draw_text_small("Nothing selected", 5, 5, get_sys_color(kColorDarkEdge));
draw_text_small("Nothing selected", 4, 4, get_sys_color(kColorTextNormal));
case evPaint:
draw_text_small("Nothing selected", 5, 5, get_sys_color(brDarkEdge));
draw_text_small("Nothing selected", 4, 4, get_sys_color(brTextNormal));
return true;
case kToolBarMessageButtonClick:
for (int i = 0; i < win->num_toolbar_buttons; i++) {
toolbar_button_t *but = &win->toolbar_buttons[i];
but->active = (but->ident == wparam);
}
case tbButtonClick:
send_message(win, tbSetActiveButton, wparam, NULL);
set_selection_mode(editor, wparam);
invalidate_window(win);
return true;
Expand All @@ -87,13 +84,13 @@ result_t win_sector(window_t *win, uint32_t msg, uint32_t wparam, void *lparam)
editor_state_t *editor = get_editor();
mapsector_t *sector = selected_sector(g_game);
switch (msg) {
case kWindowMessageCreate:
case evCreate:
win->userdata = lparam;
g_inspector = win;
load_window_children(win, sector_layout);
// init_combobox(get_window_item(win, ID_TEST_COMBOBOX));
return true;
case kWindowMessagePaint:
case evPaint:
if (sector) {
set_window_item_text(win, ID_SECTOR_IDENT, "%d", sector - g_game->map.sectors);
set_window_item_text(win, ID_SECTOR_LIGHT_LEVEL, "%d", sector->lightlevel);
Expand All @@ -103,16 +100,16 @@ result_t win_sector(window_t *win, uint32_t msg, uint32_t wparam, void *lparam)
set_window_item_text(win, ID_SECTOR_CEILING_IMAGE, sector->ceilingpic);
}
return false;
case kWindowMessageCommand:
case evCommand:
if (sector) {
switch (wparam) {
case MAKEDWORD(ID_SECTOR_LIGHT_LEVEL, kEditNotificationUpdate):
case MAKEDWORD(ID_SECTOR_LIGHT_LEVEL, edUpdate):
sector->lightlevel = atoi(((window_t *)lparam)->title);
break;
case MAKEDWORD(ID_SECTOR_FLOOR_HEIGHT, kEditNotificationUpdate):
case MAKEDWORD(ID_SECTOR_FLOOR_HEIGHT, edUpdate):
sector->floorheight = atoi(((window_t *)lparam)->title);
break;
case MAKEDWORD(ID_SECTOR_CEILING_HEIGHT, kEditNotificationUpdate):
case MAKEDWORD(ID_SECTOR_CEILING_HEIGHT, edUpdate):
sector->ceilingheight = atoi(((window_t *)lparam)->title);
break;
}
Expand Down
Loading
Loading