Add menu loading for iw4

This commit is contained in:
Jan 2020-09-08 20:52:29 +02:00
parent 18bd0ab524
commit bdbfb7114e
6 changed files with 604 additions and 24 deletions

View File

@ -24,8 +24,8 @@ ZoneCode.Assets = {
-- "GfxWorld",
-- "GfxLightDef",
-- "Font_s",
-- "MenuList",
-- "menuDef_t",
"MenuList",
"menuDef_t",
"LocalizeEntry",
-- "WeaponCompleteDef",
-- "SndDriverGlobals",

View File

@ -24,8 +24,8 @@ asset LoadedSound ASSET_TYPE_LOADED_SOUND;
// asset GfxWorld ASSET_TYPE_GFXWORLD;
// asset GfxLightDef ASSET_TYPE_LIGHT_DEF;
// asset Font_s ASSET_TYPE_FONT;
// asset MenuList ASSET_TYPE_MENULIST;
// asset menuDef_t ASSET_TYPE_MENU;
asset MenuList ASSET_TYPE_MENULIST;
asset menuDef_t ASSET_TYPE_MENU;
asset LocalizeEntry ASSET_TYPE_LOCALIZE_ENTRY;
// asset WeaponCompleteDef ASSET_TYPE_WEAPON;
// asset SndDriverGlobals ASSET_TYPE_SNDDRIVER_GLOBALS;
@ -407,6 +407,164 @@ set string name;
set name name;
set string value;
// =========================================
// MenuList
// =========================================
use MenuList;
set string name;
set name name;
set count menus menuCount;
// =========================================
// menuDef_t
// =========================================
use menuDef_t;
set string window::name;
set name window::name;
set string font;
set reusable visibleExp;
set string allowedBinding;
set string soundName;
set reusable rectXExp;
set reusable rectYExp;
set reusable rectWExp;
set reusable rectHExp;
set reusable openSoundExp;
set reusable closeSoundExp;
set count items itemCount;
set reusable expressionData;
reorder:
expressionData
window
font
onOpen
onClose
onCloseRequest
onESC
onKey
visibleExp
allowedBinding
soundName
rectXExp
rectYExp
rectWExp
rectHExp
openSoundExp
closeSoundExp
items;
// windowDef_t
use windowDef_t;
set string name;
set string group;
// MenuEventHandlerSet
set count MenuEventHandlerSet::eventHandlers eventHandlerCount;
// MenuEventHandler
use MenuEventHandler;
set string eventData::unconditionalScript;
set condition eventData::unconditionalScript eventType == EVENT_UNCONDITIONAL;
set condition eventData::conditionalScript eventType == EVENT_IF;
set condition eventData::elseScript eventType == EVENT_ELSE;
set condition eventData::setLocalVarData eventType == EVENT_SET_LOCAL_VAR_BOOL
|| eventType == EVENT_SET_LOCAL_VAR_INT
|| eventType == EVENT_SET_LOCAL_VAR_FLOAT
|| eventType == EVENT_SET_LOCAL_VAR_STRING;
// ConditionalScript
use ConditionalScript;
set reusable eventExpression;
reorder:
eventExpression
eventHandlerSet;
// SetLocalVarData
use SetLocalVarData;
set string localVarName;
set reusable expression;
// Statement_s
use Statement_s;
set count entries numEntries;
set reusable supportingData;
set condition lastResult never;
// expressionEntry
set condition expressionEntry::data::operand type == EET_OPERAND;
// Operand
use Operand;
set reusable internals::function;
set condition internals::intVal dataType == VAL_INT;
set condition internals::floatVal dataType == VAL_FLOAT;
set condition internals::stringVal dataType == VAL_STRING;
set condition internals::function dataType == VAL_FUNCTION;
// ExpressionString
set string ExpressionString::string;
// itemDef_s
use itemDef_s;
set string text;
set condition parent never;
set string dvar;
set string dvarTest;
set string enableDvar;
set string localVar;
set count floatExpressions floatExpressionCount;
set reusable visibleExp;
set reusable disabledExp;
set reusable textExp;
set reusable materialExp;
// itemDefData_t
use itemDefData_t;
set string enumDvarName;
set condition data never;
set condition listBox itemDef_s::type == 6;
set condition editField itemDef_s::type == 0
|| itemDef_s::type == 4
|| itemDef_s::type == 9
|| itemDef_s::type == 10
|| itemDef_s::type == 11
|| itemDef_s::type == 14
|| itemDef_s::type == 16
|| itemDef_s::type == 17
|| itemDef_s::type == 18
|| itemDef_s::type == 22
|| itemDef_s::type == 23;
set condition multi itemDef_s::type == 12;
set condition enumDvarName itemDef_s::type == 13;
set condition ticker itemDef_s::type == 20;
set condition scroll itemDef_s::type == 21;
// multiDef_s
use multiDef_s;
set string dvarList;
set string dvarStr;
// ItemFloatExpression
set reusable ItemFloatExpression::expression;
// UIFunctionList
use UIFunctionList;
set count functions totalFunctions;
set reusable functions; // This statement makes both the array of pointers and the pointers in the array reusable. only the second one is correct however this shouldn't be a problem with vanilla fastfiles.
// StaticDvarList
set count StaticDvarList::staticDvars numStaticDvars;
// StaticDvar
use StaticDvar;
set condition dvar never;
set string dvarName;
// StringList
use StringList;
set count strings totalStrings;
set string strings;
// =========================================
// RawFile
// =========================================

View File

@ -125,8 +125,8 @@ GameAssetPoolIW4::GameAssetPoolIW4(const int priority)
// m_gfx_world = nullptr;
// m_gfx_light_def = nullptr;
// m_font = nullptr;
// m_menu_list = nullptr;
// m_menu_def = nullptr;
m_menu_list = nullptr;
m_menu_def = nullptr;
m_localize = nullptr;
// m_weapon = nullptr;
// m_snd_driver_globals = nullptr;
@ -178,8 +178,8 @@ void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capa
// CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals);
@ -238,8 +238,8 @@ void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type)
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals);
@ -307,8 +307,8 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string nam
// CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
// CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
// CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font);
// CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
// CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize);
// CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon);
// CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, sndDriverGlobals);
@ -367,8 +367,8 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri
// CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world);
// CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def);
// CASE_GET_ASSET(ASSET_TYPE_FONT, m_font);
// CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
// CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize);
// CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon);
// CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals);

View File

@ -37,8 +37,8 @@ public:
// std::unique_ptr<AssetPool<IW4::GfxWorld>> m_gfx_world;
// std::unique_ptr<AssetPool<IW4::GfxLightDef>> m_gfx_light_def;
// std::unique_ptr<AssetPool<IW4::Font_s>> m_font;
// std::unique_ptr<AssetPool<IW4::MenuList>> m_menu_list;
// std::unique_ptr<AssetPool<IW4::menuDef_t>> m_menu_def;
std::unique_ptr<AssetPool<IW4::MenuList>> m_menu_list;
std::unique_ptr<AssetPool<IW4::menuDef_t>> m_menu_def;
std::unique_ptr<AssetPool<IW4::LocalizeEntry>> m_localize;
// std::unique_ptr<AssetPool<IW4::WeaponCompleteDef>> m_weapon;
// std::unique_ptr<AssetPool<IW4::SndDriverGlobals>> m_snd_driver_globals;

View File

@ -96,8 +96,8 @@ namespace IW4
// struct GfxWorld;
// struct GfxLightDef;
// struct Font_s;
// struct MenuList;
// struct menuDef_t;
struct MenuList;
struct menuDef_t;
struct LocalizeEntry;
// struct WeaponCompleteDef;
// struct SndDriverGlobals;
@ -105,6 +105,7 @@ namespace IW4
// struct FxImpactTable;
struct RawFile;
struct StringTable;
// struct LeaderboardDef;
// struct StructuredDataDefSet;
// struct TracerDef;
@ -136,8 +137,8 @@ namespace IW4
// GfxWorld* gfxWorld;
// GfxLightDef* lightDef;
// Font_s* font;
// MenuList* menuList;
// menuDef_t* menu;
MenuList* menuList;
menuDef_t* menu;
LocalizeEntry* localize;
// WeaponCompleteDef* weapon;
// SndDriverGlobals* sndDriverGlobals;
@ -941,11 +942,13 @@ namespace IW4
float distMax;
float velocityMin;
int flags;
union
{
float slavePercentage;
float masterPercentage;
};
float probability;
float lfePercentage;
float centerPercentage;
@ -977,6 +980,425 @@ namespace IW4
const char* name;
};
struct StringList
{
int totalStrings;
const char** strings;
};
union DvarLimits
{
struct
{
int stringCount;
const char** strings;
} enumeration;
struct
{
int min;
int max;
} integer;
struct
{
float min;
float max;
} value;
struct
{
float min;
float max;
} vector;
};
union DvarValue
{
bool enabled;
int integer;
unsigned int unsignedInt;
float value;
float vector[4];
const char* string;
char color[4];
};
struct dvar_t
{
const char* name;
const char* description;
unsigned int flags;
char type;
bool modified;
DvarValue current;
DvarValue latched;
DvarValue reset;
DvarLimits domain;
//bool (__cdecl* domainFunc)(dvar_t*, DvarValue);
void* domainFunc;
dvar_t* hashNext;
};
struct StaticDvar
{
dvar_t* dvar;
char* dvarName;
};
struct StaticDvarList
{
int numStaticDvars;
StaticDvar** staticDvars;
};
struct ExpressionString
{
const char* string;
};
struct Statement_s;
union operandInternalDataUnion
{
int intVal;
float floatVal;
ExpressionString stringVal;
Statement_s* function;
};
enum expDataType
{
VAL_INT = 0x0,
VAL_FLOAT = 0x1,
VAL_STRING = 0x2,
NUM_INTERNAL_DATATYPES = 0x3,
VAL_FUNCTION = 0x3,
NUM_DATATYPES = 0x4,
};
struct Operand
{
expDataType dataType;
operandInternalDataUnion internals;
};
union entryInternalData
{
int op;
Operand operand;
};
enum expressionEntryType : int
{
EET_OPERATOR = 0x0,
EET_OPERAND = 0x1,
};
struct expressionEntry
{
expressionEntryType type;
entryInternalData data;
};
struct ExpressionSupportingData;
struct Statement_s
{
int numEntries;
expressionEntry* entries;
ExpressionSupportingData* supportingData;
int lastExecuteTime;
Operand lastResult;
};
struct UIFunctionList
{
int totalFunctions;
Statement_s** functions;
};
struct ExpressionSupportingData
{
UIFunctionList uifunctions;
StaticDvarList staticDvarList;
StringList uiStrings;
};
struct menuTransition
{
int transitionType;
int targetField;
int startTime;
float startVal;
float endVal;
float time;
int endTriggerType;
};
struct ItemFloatExpression
{
int target;
Statement_s* expression;
};
struct columnInfo_s
{
int pos;
int width;
int maxChars;
int alignment;
};
struct MenuEventHandlerSet;
struct ConditionalScript
{
MenuEventHandlerSet* eventHandlerSet;
Statement_s* eventExpression;
};
struct SetLocalVarData
{
const char* localVarName;
Statement_s* expression;
};
union EventData
{
const char* unconditionalScript;
ConditionalScript* conditionalScript;
MenuEventHandlerSet* elseScript;
SetLocalVarData* setLocalVarData;
};
enum EventType : char
{
EVENT_UNCONDITIONAL = 0x0,
EVENT_IF = 0x1,
EVENT_ELSE = 0x2,
EVENT_SET_LOCAL_VAR_BOOL = 0x3,
EVENT_SET_LOCAL_VAR_INT = 0x4,
EVENT_SET_LOCAL_VAR_FLOAT = 0x5,
EVENT_SET_LOCAL_VAR_STRING = 0x6,
EVENT_COUNT,
};
struct MenuEventHandler
{
EventData eventData;
EventType eventType;
};
struct MenuEventHandlerSet
{
int eventHandlerCount;
MenuEventHandler** eventHandlers;
};
struct listBoxDef_s
{
int mousePos;
int startPos[1];
int endPos[1];
int drawPadding;
float elementWidth;
float elementHeight;
int elementStyle;
int numColumns;
columnInfo_s columnInfo[16];
MenuEventHandlerSet* onDoubleClick;
int notselectable;
int noScrollBars;
int usePaging;
float selectBorder[4];
Material* selectIcon;
};
struct editFieldDef_s
{
float minVal;
float maxVal;
float defVal;
float range;
int maxChars;
int maxCharsGotoNext;
int maxPaintChars;
int paintOffset;
};
struct multiDef_s
{
const char* dvarList[32];
const char* dvarStr[32];
float dvarValue[32];
int count;
int strDef;
};
struct newsTickerDef_s
{
int feedId;
int speed;
int spacing;
int lastTime;
int start;
int end;
float x;
};
struct textScrollDef_s
{
int startTime;
};
union itemDefData_t
{
listBoxDef_s* listBox;
editFieldDef_s* editField;
multiDef_s* multi;
const char* enumDvarName;
newsTickerDef_s* ticker;
textScrollDef_s* scroll;
void* data;
};
struct ItemKeyHandler
{
int key;
MenuEventHandlerSet* action;
ItemKeyHandler* next;
};
struct __declspec(align(4)) rectDef_s
{
float x;
float y;
float w;
float h;
char horzAlign;
char vertAlign;
};
struct windowDef_t
{
const char* name;
rectDef_s rect;
rectDef_s rectClient;
const char* group;
int style;
int border;
int ownerDraw;
int ownerDrawFlags;
float borderSize;
int staticFlags;
int dynamicFlags[1];
int nextTime;
float foreColor[4];
float backColor[4];
float borderColor[4];
float outlineColor[4];
float disableColor[4];
Material* background;
};
struct itemDef_s
{
windowDef_t window;
rectDef_s textRect[1];
int type;
int dataType;
int alignment;
int fontEnum;
int textAlignMode;
float textalignx;
float textaligny;
float textscale;
int textStyle;
int gameMsgWindowIndex;
int gameMsgWindowMode;
const char* text;
int itemFlags;
menuDef_t* parent;
MenuEventHandlerSet* mouseEnterText;
MenuEventHandlerSet* mouseExitText;
MenuEventHandlerSet* mouseEnter;
MenuEventHandlerSet* mouseExit;
MenuEventHandlerSet* action;
MenuEventHandlerSet* accept;
MenuEventHandlerSet* onFocus;
MenuEventHandlerSet* leaveFocus;
const char* dvar;
const char* dvarTest;
ItemKeyHandler* onKey;
const char* enableDvar;
const char* localVar;
int dvarFlags;
snd_alias_list_t* focusSound;
float special;
int cursorPos[1];
itemDefData_t typeData;
int imageTrack;
int floatExpressionCount;
ItemFloatExpression* floatExpressions;
Statement_s* visibleExp;
Statement_s* disabledExp;
Statement_s* textExp;
Statement_s* materialExp;
float glowColor[4];
bool decayActive;
int fxBirthTime;
int fxLetterTime;
int fxDecayStartTime;
int fxDecayDuration;
int lastSoundPlayedTime;
};
struct menuDef_t
{
windowDef_t window;
const char* font;
int fullScreen;
int itemCount;
int fontIndex;
int cursorItem[1];
int fadeCycle;
float fadeClamp;
float fadeAmount;
float fadeInAmount;
float blurRadius;
MenuEventHandlerSet* onOpen;
MenuEventHandlerSet* onCloseRequest;
MenuEventHandlerSet* onClose;
MenuEventHandlerSet* onESC;
ItemKeyHandler* onKey;
Statement_s* visibleExp;
const char* allowedBinding;
const char* soundName;
int imageTrack;
float focusColor[4];
Statement_s* rectXExp;
Statement_s* rectYExp;
Statement_s* rectWExp;
Statement_s* rectHExp;
Statement_s* openSoundExp;
Statement_s* closeSoundExp;
itemDef_s** items;
menuTransition scaleTransition[1];
menuTransition alphaTransition[1];
menuTransition xTransition[1];
menuTransition yTransition[1];
ExpressionSupportingData* expressionData;
};
struct MenuList
{
const char* name;
int menuCount;
menuDef_t** menus;
};
#ifndef __zonecodegenerator
}
#endif

View File

@ -25,8 +25,8 @@
#include "Game/IW4/XAssets/materialtechniqueset/materialtechniqueset_load_db.h"
#include "Game/IW4/XAssets/materialvertexdeclaration/materialvertexdeclaration_load_db.h"
#include "Game/IW4/XAssets/materialvertexshader/materialvertexshader_load_db.h"
//#include "Game/IW4/XAssets/menudef_t/menudef_t_load_db.h"
//#include "Game/IW4/XAssets/menulist/menulist_load_db.h"
#include "Game/IW4/XAssets/menudef_t/menudef_t_load_db.h"
#include "Game/IW4/XAssets/menulist/menulist_load_db.h"
#include "Game/IW4/XAssets/physcollmap/physcollmap_load_db.h"
#include "Game/IW4/XAssets/physpreset/physpreset_load_db.h"
#include "Game/IW4/XAssets/rawfile/rawfile_load_db.h"
@ -126,8 +126,8 @@ void ContentLoaderIW4::LoadXAsset(const bool atStreamStart)
// LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld);
// LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef);
// LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font);
// LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList);
// LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu);
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList);
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu);
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize);
// LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon);
SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals);