From 93a3ff34e885297057dedcd6decc6a26ead4575f Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sun, 25 Jan 2015 12:16:58 +0000 Subject: [PATCH] Add events EVENT_DISPLAYINACTIVEMENU and EVENT_DISPLAYINACTIVEMENUREST and userdef members m_origin_x and m_origin_y. This allows for CON screen display code to use menu animations. The following is an example of how to adapt screen features that should animate. before: onevent EVENT_DISPLAYMENUREST ifvare current_menu 0 // main menu { setvar x 1 setvar y 1 rotatesprite x y zoom ang tilenum shade pal orientation 0 0 xdim ydim } endevent after: state DisplayMenuCommon ifvare RETURN 0 // main menu { getuserdef[THISACTOR].m_origin_x x getuserdef[THISACTOR].m_origin_y y addvar x 65536 addvar y 65536 rotatesprite16 x y zoom ang tilenum shade pal orientation 0 0 xdim ydim } ends onevent EVENT_DISPLAYMENUREST state DisplayMenuCommon endevent onevent EVENT_DISPLAYINACTIVEMENUREST state DisplayMenuCommon endevent git-svn-id: https://svn.eduke32.com/eduke32@4945 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/events_defs.h | 2 ++ polymer/eduke32/source/game.h | 2 ++ polymer/eduke32/source/gamedef.c | 5 +++ polymer/eduke32/source/gamedef.h | 2 ++ polymer/eduke32/source/gamestructures.c | 4 +++ polymer/eduke32/source/lunatic/con_lang.lua | 9 ++++-- polymer/eduke32/source/lunatic/defs.ilua | 2 ++ polymer/eduke32/source/menus.c | 35 +++++++++++++++------ 8 files changed, 49 insertions(+), 12 deletions(-) diff --git a/polymer/eduke32/source/events_defs.h b/polymer/eduke32/source/events_defs.h index 84827153c..1a5c3158e 100644 --- a/polymer/eduke32/source/events_defs.h +++ b/polymer/eduke32/source/events_defs.h @@ -102,6 +102,8 @@ enum GameEvent_t { EVENT_CHANGEMENU, EVENT_DAMAGEHPLANE, // 95 EVENT_ACTIVATECHEAT, + EVENT_DISPLAYINACTIVEMENU, + EVENT_DISPLAYINACTIVEMENUREST, #ifdef LUNATIC EVENT_ANIMATEALLSPRITES, #endif diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h index b61d39a0a..9ed5390ae 100644 --- a/polymer/eduke32/source/game.h +++ b/polymer/eduke32/source/game.h @@ -166,6 +166,8 @@ typedef struct { int32_t m_ffire,ffire,m_player_skill,m_level_number,m_volume_number,multimode; int32_t player_skill,level_number,volume_number,m_marker,marker,mouseflip; + vec2_t m_origin; + int32_t configversion; #if !defined LUNATIC int16_t cameraang, camerasect, camerahoriz; diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 461ffda2e..0192c75cf 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -656,6 +656,8 @@ const char *EventNames[MAXEVENTS] = "EVENT_CHANGEMENU", "EVENT_DAMAGEHPLANE", "EVENT_ACTIVATECHEAT", + "EVENT_DISPLAYINACTIVEMENU", + "EVENT_DISPLAYINACTIVEMENUREST", #ifdef LUNATIC "EVENT_ANIMATEALLSPRITES", #endif @@ -1054,6 +1056,9 @@ const memberlabel_t UserdefsLabels[]= { "fola", USERDEFS_FOLA, 0, 0 }, { "reccnt", USERDEFS_RECCNT, 0, 0 }, + { "m_origin_x", USERDEFS_M_ORIGIN_X, 0, 0 }, + { "m_origin_y", USERDEFS_M_ORIGIN_Y, 0, 0 }, + { "entered_name", USERDEFS_ENTERED_NAME, 0, 0 }, { "screen_tilting", USERDEFS_SCREEN_TILTING, 0, 0 }, { "shadows", USERDEFS_SHADOWS, 0, 0 }, diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index 518be7b65..40c412f2e 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -423,6 +423,8 @@ enum UserdefsLabel_t USERDEFS_WEAPONSCALE, USERDEFS_TEXTSCALE, USERDEFS_RUNKEY_MODE, + USERDEFS_M_ORIGIN_X, + USERDEFS_M_ORIGIN_Y, USERDEFS_END }; diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c index 25cae19ff..3990ac284 100644 --- a/polymer/eduke32/source/gamestructures.c +++ b/polymer/eduke32/source/gamestructures.c @@ -145,6 +145,8 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t case USERDEFS_WEAPONSCALE: ud.weaponscale = iSet; break; case USERDEFS_TEXTSCALE: ud.textscale = iSet; break; case USERDEFS_RUNKEY_MODE: ud.runkey_mode = iSet; break; + case USERDEFS_M_ORIGIN_X: ud.m_origin.x = iSet; break; + case USERDEFS_M_ORIGIN_Y: ud.m_origin.y = iSet; break; default: break; } } @@ -247,6 +249,8 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t case USERDEFS_WEAPONSCALE: lLabelID = ud.weaponscale; break; case USERDEFS_TEXTSCALE: lLabelID = ud.textscale; break; case USERDEFS_RUNKEY_MODE: lLabelID = ud.runkey_mode; break; + case USERDEFS_M_ORIGIN_X: lLabelID = ud.m_origin.x; break; + case USERDEFS_M_ORIGIN_Y: lLabelID = ud.m_origin.y; break; default: lLabelID = -1; break; } Gv_SetVarX(lVar2, lLabelID); diff --git a/polymer/eduke32/source/lunatic/con_lang.lua b/polymer/eduke32/source/lunatic/con_lang.lua index aa720cc91..fede58eae 100644 --- a/polymer/eduke32/source/lunatic/con_lang.lua +++ b/polymer/eduke32/source/lunatic/con_lang.lua @@ -170,10 +170,13 @@ EVENT = { EVENT_CHANGEMENU = 94, EVENT_DAMAGEHPLANE = 95, EVENT_ACTIVATECHEAT = 96, --- EVENT_ANIMATEALLSPRITES = 97, -- internal + EVENT_DISPLAYINACTIVEMENU = 97, + EVENT_DISPLAYINACTIVEMENUREST = 98, +-- EVENT_ANIMATEALLSPRITES = previous+1, -- internal +-- KEEPINSYNC with MAXEVENTS below } -MAXEVENTS = 97 -- KEEPINSYNC with above EVENT_* list +MAXEVENTS = 99 -- KEEPINSYNC with above EVENT_* list -- NOTE: negated values are not exported to the ffi.C namespace or CON. -- See TWEAK_SFLAG below. @@ -857,6 +860,8 @@ local UserdefLabels = { level_number = { UD".level_number", UD":set_level_number(%%s)", {0, MAXLEVELS-1} }, levelstats = UD".levelstats", lockout = UDRO".lockout", + m_origin_x = UD".m_origin.x", + m_origin_y = UD".m_origin.y", m_player_skill = UDRO".m_player_skill", m_volume_number = { UD".m_volume_number", UD":set_m_volume_number(%%s)", {0, MAXVOLUMES} }, mouseaiming = UD".mouseaiming", diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index e7df7a299..ca2bc6260 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -512,6 +512,8 @@ typedef struct { int32_t m_ffire,ffire,m_player_skill,m_level_number,m_volume_number,multimode; int32_t player_skill,level_number,volume_number,m_marker,marker,mouseflip; + vec2_t m_origin; + int32_t configversion; int16_t pause_on,from_bonus; diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 902bd08d0..43647af4f 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -5490,7 +5490,7 @@ static void M_RunMenuInput(Menu_t *cm) // This function MUST NOT RECURSE. That is why M_RunMenu is separate. void M_DisplayMenus(void) { - vec2_t origin = { 0, 0 }; + vec2_t origin = { 0, 0 }, previousOrigin = { 0, 0 }; Net_GetPackets(); @@ -5509,7 +5509,22 @@ void M_DisplayMenus(void) M_RunMenuInput(m_currentMenu); - VM_OnEvent(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek); + // Determine animation values. + if (totalclock < m_animation.start + m_animation.length) + { + const int32_t screenwidth = scale(240<<16, xdim, ydim); + + origin.x = scale(screenwidth, m_animation.in(&m_animation), 32768); + previousOrigin.x = scale(screenwidth, m_animation.out(&m_animation), 32768); + + ud.m_origin = previousOrigin; + VM_OnEventWithReturn(EVENT_DISPLAYINACTIVEMENU, g_player[screenpeek].ps->i, screenpeek, m_animation.previous->menuID); + previousOrigin = ud.m_origin; + } + + ud.m_origin = origin; + VM_OnEventWithReturn(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek, g_currentMenu); + origin = ud.m_origin; g_player[myconnectindex].ps->gm &= (0xff-MODE_TYPE); g_player[myconnectindex].ps->fta = 0; @@ -5528,12 +5543,6 @@ void M_DisplayMenus(void) // Display the menu, with a transition animation if applicable. if (totalclock < m_animation.start + m_animation.length) { - vec2_t previousOrigin = { 0, 0 }; - const int32_t screenwidth = scale(240<<16, xdim, ydim); - - origin.x = scale(screenwidth, m_animation.in(&m_animation), 32768); - previousOrigin.x = scale(screenwidth, m_animation.out(&m_animation), 32768); - M_RunMenu(m_animation.previous, previousOrigin); M_RunMenu(m_animation.current, origin); } @@ -5545,8 +5554,14 @@ void M_DisplayMenus(void) m_menuchange_watchpoint = 0; #endif - if (VM_HaveEvent(EVENT_DISPLAYMENUREST)) - VM_OnEvent(EVENT_DISPLAYMENUREST, g_player[screenpeek].ps->i, screenpeek); + if (totalclock < m_animation.start + m_animation.length) + { + ud.m_origin = previousOrigin; + VM_OnEventWithReturn(EVENT_DISPLAYINACTIVEMENUREST, g_player[screenpeek].ps->i, screenpeek, m_animation.previous->menuID); + } + + ud.m_origin = origin; + VM_OnEventWithReturn(EVENT_DISPLAYMENUREST, g_player[screenpeek].ps->i, screenpeek, g_currentMenu); #if !defined EDUKE32_TOUCH_DEVICES if (tilesiz[CROSSHAIR].x > 0 && mousestatus)