From: Daniel Karbach Date: Fri, 30 Nov 2012 15:38:21 +0000 (+0100) Subject: moved menu resources to data files X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=0285546b22f9e8f496ca6b1abffdd232647b6b6a;p=l2e.git moved menu resources to data files --- diff --git a/src/graphics/Menu.cpp b/src/graphics/Menu.cpp index b1e6af9..6527e3e 100644 --- a/src/graphics/Menu.cpp +++ b/src/graphics/Menu.cpp @@ -19,6 +19,7 @@ void MenuProperties::CreateTypeDescription() { td.AddField("font", FieldDescription(((char *)&p.font) - ((char *)&p), Font::TYPE_ID).SetReferenced().SetDescription("the font to use for normal/enabled entries")); td.AddField("disabledFont", FieldDescription(((char *)&p.disabledFont) - ((char *)&p), Font::TYPE_ID).SetReferenced().SetDescription("the font for disabled entries")); td.AddField("cursor", FieldDescription(((char *)&p.cursor) - ((char *)&p), Sprite::TYPE_ID).SetReferenced().SetDescription("the cursor sprite indicating the current selection")); + td.AddField("selectedCursor", FieldDescription(((char *)&p.selectedCursor) - ((char *)&p), Sprite::TYPE_ID).SetReferenced().SetDescription("the cursor sprite used when fixating a selection")); td.AddField("charsPerEntry", FieldDescription(((char *)&p.charsPerEntry) - ((char *)&p), Interpreter::NUMBER_ID).SetDescription("width of an entry in characters")); td.AddField("rows", FieldDescription(((char *)&p.rows) - ((char *)&p), Interpreter::NUMBER_ID).SetDescription("number of visible rows")); td.AddField("rowGap", FieldDescription(((char *)&p.rowGap) - ((char *)&p), Interpreter::NUMBER_ID).SetDescription("space between rows in pixles")); @@ -29,6 +30,8 @@ void MenuProperties::CreateTypeDescription() { td.AddField("charsPerNumber", FieldDescription(((char *)&p.charsPerNumber) - ((char *)&p), Interpreter::NUMBER_ID).SetDescription("maximum width of a number in chars")); td.AddField("charsPerAdditionalText", FieldDescription(((char *)&p.charsPerAdditionalText) - ((char *)&p), Interpreter::NUMBER_ID).SetDescription("maximum number of additional text characters")); td.AddField("additionalTextGap", FieldDescription(((char *)&p.additionalTextGap) - ((char *)&p), Interpreter::NUMBER_ID).SetDescription("space between normal and additional text in pixels")); + td.AddField("wrapX", FieldDescription(((char *)&p.wrapX) - ((char *)&p), Interpreter::BOOLEAN_ID).SetDescription("horizontally wrap cursor movement")); + td.AddField("wrapY", FieldDescription(((char *)&p.wrapY) - ((char *)&p), Interpreter::BOOLEAN_ID).SetDescription("vertically wrap cursor movement")); } void MenuProperties::Construct(void *data) { diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp index f4a0385..f53c82f 100644 --- a/src/graphics/Texture.cpp +++ b/src/graphics/Texture.cpp @@ -1,8 +1,13 @@ #include "Texture.h" +#include "../loader/Interpreter.h" +#include "../loader/TypeDescription.h" #include "../sdl/utility.h" using geometry::Vector; +using loader::FieldDescription; +using loader::Interpreter; +using loader::TypeDescription; namespace graphics { @@ -55,4 +60,21 @@ void Texture::Render(SDL_Surface *dest, const Vector &from, const Vector &offset = geometry::Vector()); ~Texture(); + static const int TYPE_ID = 410; + public: void Render(SDL_Surface *dest, const geometry::Vector &from, const geometry::Vector &to) const; @@ -24,6 +26,9 @@ public: void SetSize(const geometry::Vector &s) { size = s; } void SetOffset(const geometry::Vector &o) { offset = o; } + static void CreateTypeDescription(); + static void Construct(void *); + private: SDL_Surface *surface; geometry::Vector size; diff --git a/src/loader/Caster.cpp b/src/loader/Caster.cpp index 876e128..78a31b5 100644 --- a/src/loader/Caster.cpp +++ b/src/loader/Caster.cpp @@ -1,6 +1,14 @@ #include "Caster.h" #include "TypeDescription.h" +#include "../battle/Resources.h" +#include "../battle/Monster.h" +#include "../battle/PartyLayout.h" +#include "../common/Hero.h" +#include "../common/Item.h" +#include "../common/Spell.h" +#include "../map/Map.h" +#include "../menu/Resources.h" using battle::Monster; using battle::PartyLayout; @@ -14,44 +22,44 @@ using std::string; namespace loader { Caster::Caster(Interpreter &intp) -: intp(intp) -, battleResourcesId(TypeDescription::GetTypeId("BattleResources")) -, heroId(TypeDescription::GetTypeId("Hero")) -, itemId(TypeDescription::GetTypeId("Item")) -, mapId(TypeDescription::GetTypeId("Map")) -, monsterId(TypeDescription::GetTypeId("Monster")) -, partyLayoutId(TypeDescription::GetTypeId("PartyLayout")) -, spellId(TypeDescription::GetTypeId("Spell")) { +: intp(intp) { } battle::Resources *Caster::GetBattleResources(const string &ident) { - return reinterpret_cast(intp.GetObject(battleResourcesId, ident)); + return reinterpret_cast( + intp.GetObject(battle::Resources::TYPE_ID, ident)); } Hero *Caster::GetHero(const string &ident) { - return reinterpret_cast(intp.GetObject(heroId, ident)); + return reinterpret_cast(intp.GetObject(Hero::TYPE_ID, ident)); } Item *Caster::GetItem(const string &ident) { - return reinterpret_cast(intp.GetObject(itemId, ident)); + return reinterpret_cast(intp.GetObject(Item::TYPE_ID, ident)); } Map *Caster::GetMap(const string &ident) { - return reinterpret_cast(intp.GetObject(mapId, ident)); + return reinterpret_cast(intp.GetObject(Map::TYPE_ID, ident)); +} + +menu::Resources *Caster::GetMenuResources(const string &ident) { + return reinterpret_cast( + intp.GetObject(menu::Resources::TYPE_ID, ident)); } Monster *Caster::GetMonster(const string &ident) { - return reinterpret_cast(intp.GetObject(monsterId, ident)); + return reinterpret_cast(intp.GetObject(Monster::TYPE_ID, ident)); } PartyLayout *Caster::GetPartyLayout(const string &ident) { - return reinterpret_cast(intp.GetObject(partyLayoutId, ident)); + return reinterpret_cast( + intp.GetObject(PartyLayout::TYPE_ID, ident)); } Spell *Caster::GetSpell(const string &ident) { - return reinterpret_cast(intp.GetObject(spellId, ident)); + return reinterpret_cast(intp.GetObject(Spell::TYPE_ID, ident)); } } diff --git a/src/loader/Caster.h b/src/loader/Caster.h index c095cc9..2aa6be0 100644 --- a/src/loader/Caster.h +++ b/src/loader/Caster.h @@ -5,6 +5,7 @@ #include "../battle/fwd.h" #include "../common/fwd.h" #include "../map/fwd.h" +#include "../menu/fwd.h" #include @@ -24,6 +25,7 @@ public: common::Hero *GetHero(const std::string &identifier); common::Item *GetItem(const std::string &identifier); map::Map *GetMap(const std::string &identifier); + menu::Resources *GetMenuResources(const std::string &identifier); battle::Monster *GetMonster(const std::string &identifier); battle::PartyLayout *GetPartyLayout(const std::string &identifier); common::Spell *GetSpell(const std::string &identifier); @@ -31,14 +33,6 @@ public: private: Interpreter &intp; - int battleResourcesId; - int heroId; - int itemId; - int mapId; - int monsterId; - int partyLayoutId; - int spellId; - }; } diff --git a/src/main.cpp b/src/main.cpp index 0e12f5b..31724d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,6 +114,7 @@ int main(int argc, char **argv) { graphics::MenuProperties::CreateTypeDescription(); graphics::SimpleAnimation::CreateTypeDescription(); graphics::Sprite::CreateTypeDescription(); + graphics::Texture::CreateTypeDescription(); map::Area::CreateTypeDescription(); map::Entity::CreateTypeDescription(); @@ -121,6 +122,8 @@ int main(int argc, char **argv) { map::Tile::CreateTypeDescription(); map::Trigger::CreateTypeDescription(); + menu::Resources::CreateTypeDescription(); + Arguments args; args.Read(argc, argv); @@ -191,6 +194,7 @@ int main(int argc, char **argv) { gameConfig.state = &gameState; gameConfig.heroesLayout = caster.GetPartyLayout("heroesLayout"); gameConfig.battleResources = caster.GetBattleResources("battleResources"); + gameConfig.menuResources = caster.GetMenuResources("menuResources"); // temporary test data SDL_Surface *bg(IMG_Load("test-data/battle-bg.png")); @@ -273,200 +277,6 @@ int main(int argc, char **argv) { gameState.heroes[3].MapEntity().SetFlags(Entity::FLAG_NONBLOCKING); gameState.heroes[2].MapEntity().AddFollower(&gameState.heroes[3].MapEntity()); - menu::Resources menuResources; - gameConfig.menuResources = &menuResources; - - Texture menubg; - menubg.SetSurface(IMG_Load("test-data/menubg.png")); - menubg.SetSize(Vector(64, 64)); - menuResources.menubg = &menubg; - - menuResources.statusFont = gameConfig.battleResources->normalFont; - - graphics::Sprite statusLabels(IMG_Load("test-data/status-labels.png"), 32, 16); - menuResources.statusLabels = &statusLabels; - - graphics::Frame statusFrame(IMG_Load("test-data/status-frame.png"), 32, 32, 32, 32); - menuResources.statusFrame = &statusFrame; - - graphics::Sprite menuFontSprite(IMG_Load("test-data/menu-font.png"), 16, 16); - graphics::Font menuFont(&menuFontSprite, 0, -2); - graphics::Sprite menuInactiveFontSprite(IMG_Load("test-data/menu-font-inactive.png"), 16, 16); - graphics::Font menuInactiveFont(&menuInactiveFontSprite, 0, -2); - - menuResources.normalFont = &menuFont; - menuResources.inactiveFont = &menuInactiveFont; - - graphics::Sprite menuCursor(IMG_Load("test-data/menu-cursor.png"), 32, 16); - menuResources.menuCursor = &menuCursor; - graphics::Sprite menuActiveCursor(IMG_Load("test-data/menu-cursor-active.png"), 32, 18); - menuResources.menuActiveCursor = &menuActiveCursor; - - graphics::MenuProperties mainMenuProperties; - mainMenuProperties.cols = 2; - mainMenuProperties.rows = 4; - mainMenuProperties.charsPerEntry = 8; - mainMenuProperties.rowGap = 8; - mainMenuProperties.colGap = 32; - mainMenuProperties.cursor = &menuCursor; - mainMenuProperties.font = &menuFont; - mainMenuProperties.wrapX = true; - mainMenuProperties.wrapY = true; - menuResources.mainMenuProperties = &mainMenuProperties; - - menuResources.mainMenuItemText = "ITEM"; - menuResources.mainMenuSpellText = "SPELL"; - menuResources.mainMenuCapsuleText = "CAPSULE"; - menuResources.mainMenuEquipmentText = "EQUIP"; - menuResources.mainMenuStatusText = "STATUS"; - menuResources.mainMenuChangeText = "CHANGE"; - menuResources.mainMenuConfigText = "CONFIG"; - menuResources.mainMenuScenarioText = "SCENARIO"; - - menuResources.mainMenuTimeText = "TIME"; - menuResources.mainMenuGoldText = "GOLD"; - - graphics::Sprite heroCursor(IMG_Load("test-data/hero-cursor.png"), 64, 16); - menuResources.heroCursor = &heroCursor; - menuResources.heroCursorBlinkTime = 532; - - menuResources.noEquipmentText = "No equip"; - - graphics::Sprite shoulderNav(IMG_Load("test-data/shoulder-nav.png"), 160, 16); - menuResources.shoulderNav = &shoulderNav; - - menuResources.atpLabel = "ATP"; - menuResources.dfpLabel = "DFP"; - menuResources.strLabel = "STR"; - menuResources.aglLabel = "AGL"; - menuResources.intLabel = "INT"; - menuResources.gutLabel = "GUT"; - menuResources.mgrLabel = "MGR"; - - menuResources.ipLabel = "IP"; - menuResources.experienceLabel = "NOW EXP"; - menuResources.nextLevelLabel = "NEXT LEVEL"; - - graphics::MenuProperties statusMenuProperties; - statusMenuProperties.cols = 2; - statusMenuProperties.rows = 1; - statusMenuProperties.charsPerEntry = 6; - statusMenuProperties.rowGap = 0; - statusMenuProperties.colGap = 16; - statusMenuProperties.cursor = &menuCursor; - statusMenuProperties.font = &menuFont; - statusMenuProperties.wrapX = true; - menuResources.statusMenuProperties = &statusMenuProperties; - - menuResources.nextLabel = "NEXT"; - menuResources.returnLabel = "RETURN"; - - graphics::MenuProperties itemMenuProperties; - itemMenuProperties.cols = 3; - itemMenuProperties.rows = 1; - itemMenuProperties.charsPerEntry = 5; - itemMenuProperties.rowGap = 8; - itemMenuProperties.colGap = 16; - itemMenuProperties.cursor = &menuCursor; - itemMenuProperties.selectedCursor = &menuActiveCursor; - itemMenuProperties.font = &menuFont; - itemMenuProperties.wrapX = true; - itemMenuProperties.wrapY = true; - menuResources.itemMenuProperties = &itemMenuProperties; - menuResources.itemMenuUseText = "USE"; - menuResources.itemMenuSortText = "SORT"; - menuResources.itemMenuDropText = "DROP"; - - graphics::MenuProperties inventoryMenuProperties; - inventoryMenuProperties.cols = 1; - inventoryMenuProperties.rows = 6; - inventoryMenuProperties.charsPerEntry = 13; - inventoryMenuProperties.rowGap = 8; - inventoryMenuProperties.cursor = &menuCursor; - inventoryMenuProperties.selectedCursor = &menuActiveCursor; - inventoryMenuProperties.font = &menuFont; - inventoryMenuProperties.disabledFont = &menuInactiveFont; - inventoryMenuProperties.iconSpace = 16; - inventoryMenuProperties.charsPerNumber = 2; - inventoryMenuProperties.delimiter = ':'; - menuResources.inventoryMenuProperties = &inventoryMenuProperties; - - graphics::MenuProperties spellMenuProperties; - spellMenuProperties.cols = 2; - spellMenuProperties.rows = 6; - spellMenuProperties.charsPerEntry = 8; - spellMenuProperties.rowGap = 8; - spellMenuProperties.colGap = 48; - spellMenuProperties.cursor = &menuCursor; - spellMenuProperties.selectedCursor = &menuActiveCursor; - spellMenuProperties.font = &menuFont; - spellMenuProperties.disabledFont = &menuInactiveFont; - spellMenuProperties.iconSpace = 0; - spellMenuProperties.charsPerNumber = 2; - spellMenuProperties.delimiter = ':'; - menuResources.spellMenuProperties = &spellMenuProperties; - - graphics::MenuProperties equipmentActionMenuProperties; - equipmentActionMenuProperties.cols = 1; - equipmentActionMenuProperties.rows = 5; - equipmentActionMenuProperties.charsPerEntry = 10; - equipmentActionMenuProperties.rowGap = 8; - equipmentActionMenuProperties.cursor = &menuCursor; - equipmentActionMenuProperties.selectedCursor = &menuActiveCursor; - equipmentActionMenuProperties.font = &menuFont; - equipmentActionMenuProperties.iconSpace = 0; - menuResources.equipmentActionMenuProperties = &equipmentActionMenuProperties; - - graphics::MenuProperties equipmentMenuProperties; - equipmentMenuProperties.cols = 1; - equipmentMenuProperties.rows = 6; - equipmentMenuProperties.charsPerEntry = 12; - equipmentMenuProperties.rowGap = 16; - equipmentMenuProperties.cursor = &menuCursor; - equipmentMenuProperties.selectedCursor = &menuActiveCursor; - equipmentMenuProperties.font = menuResources.statusFont; - equipmentMenuProperties.iconSpace = 16; - equipmentMenuProperties.wrapY = true; - menuResources.equipmentMenuProperties = &equipmentMenuProperties; - - menuResources.equipMenuEquipLabel = "EQUIP"; - menuResources.equipMenuStrongestLabel = "STRONGEST"; - menuResources.equipMenuRemoveLabel = "REMOVE"; - menuResources.equipMenuRemoveAllLabel = "REMOVE ALL"; - menuResources.equipMenuDropLabel = "DROP"; - - graphics::MenuProperties configMenuProperties; - configMenuProperties.cols = 1; - configMenuProperties.rows = 4; - configMenuProperties.charsPerEntry = 8; - configMenuProperties.rowGap = 32; - configMenuProperties.cursor = &menuCursor; - configMenuProperties.font = &menuFont; - configMenuProperties.wrapY = true; - menuResources.configMenuProperties = &configMenuProperties; - - menuResources.configMessageSpeedLabel = "MESSAGE\n SPEED"; - menuResources.configMessageSpeedFast = "FAST"; - menuResources.configMessageSpeedNormal = "NORMAL"; - menuResources.configMessageSpeedSlow = "SLOW"; - menuResources.configBattleCursorLabel = "BATTLE\n CURSOR"; - menuResources.configStatusCursorLabel = "STATUS\n CURSOR"; - menuResources.configCursorClear = "CLEAR"; - menuResources.configCursorMemory = "MEMORY"; - menuResources.configMusicLabel = "MUSIC"; - menuResources.configMusicStereo = "STEREO"; - menuResources.configMusicMono = "MONO"; - - graphics::MenuProperties scenarioMenuProperties; - scenarioMenuProperties.cols = 1; - scenarioMenuProperties.rows = 6; - scenarioMenuProperties.charsPerEntry = 14; - scenarioMenuProperties.rowGap = 8; - scenarioMenuProperties.cursor = &menuCursor; - scenarioMenuProperties.font = &menuFont; - menuResources.scenarioMenuProperties = &scenarioMenuProperties; - menuResources.scenarioMenuHeadline = "SCENARIO ITEM"; - InitScreen screen(width, height); app::State *state(0); diff --git a/src/menu/Resources.cpp b/src/menu/Resources.cpp index 5020b9c..79aecf6 100644 --- a/src/menu/Resources.cpp +++ b/src/menu/Resources.cpp @@ -1,5 +1,22 @@ #include "Resources.h" +#include "../graphics/Font.h" +#include "../graphics/Frame.h" +#include "../graphics/Menu.h" +#include "../graphics/Sprite.h" +#include "../graphics/Texture.h" +#include "../loader/Interpreter.h" +#include "../loader/TypeDescription.h" + +using graphics::Font; +using graphics::Frame; +using graphics::MenuProperties; +using graphics::Sprite; +using graphics::Texture; +using loader::FieldDescription; +using loader::Interpreter; +using loader::TypeDescription; + namespace menu { Resources::Resources() @@ -8,9 +25,6 @@ Resources::Resources() , inactiveFont(0) , statusFont(0) -, menuCursor(0) -, menuActiveCursor(0) - , statusLabels(0) , statusFrame(0) @@ -82,8 +96,99 @@ Resources::Resources() , configMusicMono(0) , scenarioMenuProperties(0) -, scenarioMenuHeadline(0) { +, scenarioMenuHeadline(0) + +{ } + + +void Resources::CreateTypeDescription() { + Resources r; + + TypeDescription &td(TypeDescription::Create(TYPE_ID, "MenuResources")); + td.SetConstructor(&Construct); + td.SetSize(sizeof(Resources)); + + td.AddField("menubg", FieldDescription(((char *)&r.menubg) - ((char *)&r), Texture::TYPE_ID).SetReferenced().SetDescription("background texture for menus")); + + td.AddField("normalFont", FieldDescription(((char *)&r.normalFont) - ((char *)&r), Font::TYPE_ID).SetReferenced().SetDescription("normal menu font")); + td.AddField("inactiveFont", FieldDescription(((char *)&r.inactiveFont) - ((char *)&r), Font::TYPE_ID).SetReferenced().SetDescription("inactive menu font")); + td.AddField("statusFont", FieldDescription(((char *)&r.statusFont) - ((char *)&r), Font::TYPE_ID).SetReferenced().SetDescription("status font")); + + td.AddField("statusLabels", FieldDescription(((char *)&r.statusLabels) - ((char *)&r), Sprite::TYPE_ID).SetReferenced().SetDescription("labels for the hero status")); + td.AddField("statusFrame", FieldDescription(((char *)&r.statusFrame) - ((char *)&r), Frame::TYPE_ID).SetReferenced().SetDescription("frame for almost every menu")); + + td.AddField("mainMenu", FieldDescription(((char *)&r.mainMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the main menu")); + td.AddField("mainMenuItemText", FieldDescription(((char *)&r.mainMenuItemText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("mainMenuSpellText", FieldDescription(((char *)&r.mainMenuSpellText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("mainMenuCapsuleText", FieldDescription(((char *)&r.mainMenuCapsuleText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("mainMenuEquipmentText", FieldDescription(((char *)&r.mainMenuEquipmentText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("mainMenuStatusText", FieldDescription(((char *)&r.mainMenuStatusText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("mainMenuChangeText", FieldDescription(((char *)&r.mainMenuChangeText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("mainMenuConfigText", FieldDescription(((char *)&r.mainMenuConfigText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("mainMenuScenarioText", FieldDescription(((char *)&r.mainMenuScenarioText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + + td.AddField("mainMenuTimeText", FieldDescription(((char *)&r.mainMenuTimeText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("mainMenuGoldText", FieldDescription(((char *)&r.mainMenuGoldText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + + td.AddField("heroCursor", FieldDescription(((char *)&r.heroCursor) - ((char *)&r), Sprite::TYPE_ID).SetReferenced().SetDescription("cursor for selecting a hero")); + td.AddField("heroCursorBlinkTime", FieldDescription(((char *)&r.heroCursorBlinkTime) - ((char *)&r), Interpreter::NUMBER_ID).SetReferenced().SetDescription("blinking interval (half) for the hero cursor")); + + td.AddField("noEquipmentText", FieldDescription(((char *)&r.noEquipmentText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + + td.AddField("shoulderNav", FieldDescription(((char *)&r.shoulderNav) - ((char *)&r), Sprite::TYPE_ID).SetReferenced().SetDescription("visual aid for the hero navigation via shoulder buttons in some sub menus")); + + td.AddField("atpLabel", FieldDescription(((char *)&r.atpLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("dfpLabel", FieldDescription(((char *)&r.dfpLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("strLabel", FieldDescription(((char *)&r.strLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("aglLabel", FieldDescription(((char *)&r.aglLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("intLabel", FieldDescription(((char *)&r.intLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("gutLabel", FieldDescription(((char *)&r.gutLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("mgrLabel", FieldDescription(((char *)&r.mgrLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + + td.AddField("ipLabel", FieldDescription(((char *)&r.ipLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("experienceLabel", FieldDescription(((char *)&r.experienceLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("nextLevelLabel", FieldDescription(((char *)&r.nextLevelLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + + td.AddField("statusMenu", FieldDescription(((char *)&r.statusMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the status menu")); + + td.AddField("nextLabel", FieldDescription(((char *)&r.nextLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("returnLabel", FieldDescription(((char *)&r.returnLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + + td.AddField("itemMenu", FieldDescription(((char *)&r.itemMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the item menu")); + td.AddField("itemMenuUseText", FieldDescription(((char *)&r.itemMenuUseText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("itemMenuSortText", FieldDescription(((char *)&r.itemMenuSortText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("itemMenuDropText", FieldDescription(((char *)&r.itemMenuDropText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + + td.AddField("inventoryMenu", FieldDescription(((char *)&r.inventoryMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the inventory menu")); + td.AddField("spellMenu", FieldDescription(((char *)&r.spellMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the spell menu")); + + td.AddField("equipmentActionMenu", FieldDescription(((char *)&r.equipmentActionMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the equipment action menu (the lower one)")); + td.AddField("equipmentMenu", FieldDescription(((char *)&r.equipmentMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the equipment menu (the one with the equipped items)")); + td.AddField("equipMenuEquipLabel", FieldDescription(((char *)&r.equipMenuEquipLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("equipMenuStrongestLabel", FieldDescription(((char *)&r.equipMenuStrongestLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("equipMenuRemoveLabel", FieldDescription(((char *)&r.equipMenuRemoveLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("equipMenuRemoveAllLabel", FieldDescription(((char *)&r.equipMenuRemoveAllLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("equipMenuDropLabel", FieldDescription(((char *)&r.equipMenuDropLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + + td.AddField("configMenu", FieldDescription(((char *)&r.configMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the configuration menu")); + td.AddField("configMessageSpeedLabel", FieldDescription(((char *)&r.configMessageSpeedLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("configMessageSpeedFast", FieldDescription(((char *)&r.configMessageSpeedFast) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("configMessageSpeedNormal", FieldDescription(((char *)&r.configMessageSpeedNormal) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("configMessageSpeedSlow", FieldDescription(((char *)&r.configMessageSpeedSlow) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("configBattleCursorLabel", FieldDescription(((char *)&r.configBattleCursorLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("configStatusCursorLabel", FieldDescription(((char *)&r.configStatusCursorLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("configCursorClear", FieldDescription(((char *)&r.configCursorClear) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("configCursorMemory", FieldDescription(((char *)&r.configCursorMemory) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("configMusicLabel", FieldDescription(((char *)&r.configMusicLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("configMusicStereo", FieldDescription(((char *)&r.configMusicStereo) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("configMusicMono", FieldDescription(((char *)&r.configMusicMono) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + + td.AddField("scenarioMenu", FieldDescription(((char *)&r.scenarioMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the scenario menu")); + td.AddField("scenarioMenuHeadline", FieldDescription(((char *)&r.scenarioMenuHeadline) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); +} +void Resources::Construct(void *data) { + new (data) Resources; } } diff --git a/src/menu/Resources.h b/src/menu/Resources.h index ec1fdf4..9ea26e6 100644 --- a/src/menu/Resources.h +++ b/src/menu/Resources.h @@ -7,15 +7,14 @@ namespace menu { struct Resources { + static const int TYPE_ID = 701; + graphics::Texture *menubg; graphics::Font *normalFont; graphics::Font *inactiveFont; graphics::Font *statusFont; - graphics::Sprite *menuCursor; - graphics::Sprite *menuActiveCursor; - graphics::Sprite *statusLabels; graphics::Frame *statusFrame; @@ -91,6 +90,9 @@ struct Resources { Resources(); + static void CreateTypeDescription(); + static void Construct(void *); + }; } diff --git a/test-data/test.l2s b/test-data/test.l2s index 5f4fe2c..8491b37 100644 --- a/test-data/test.l2s +++ b/test-data/test.l2s @@ -647,4 +647,193 @@ export BattleResources battleResources { noEquipmentText: "No equip", escapeText: "Escapes." -} \ No newline at end of file +} + +Font menuFont { + sprite: Sprite { + image: :"menu-font.png", + size: <16, 16> + }, + rowoffset: -2 +} +Font menuInactiveFont { + sprite: Sprite { + image: :"menu-font-inactive.png", + size: <16, 16> + }, + rowoffset: -2 +} +Sprite menuCursor { + image: :"menu-cursor.png", + size: <32, 16> +} +Sprite menuActiveCursor { + image: :"menu-cursor-active.png", + size: <32, 18> +} + +export MenuResources menuResources { + menubg: Texture { + image: :"menubg.png", + size: <64, 64> + }, + normalFont: menuFont, + inactiveFont: menuInactiveFont, + statusFont: normalFont, + statusLabels: Sprite { + image: :"status-labels.png", + size: <32, 16> + }, + statusFrame: Frame { + image: :"status-frame.png", + border: <32, 32>, + repeat: <32, 32> + }, + mainMenu: MenuProperties { + cols: 2, + rows: 4, + charsPerEntry: 8, + rowGap: 8, + colGap: 32, + cursor: menuCursor, + font: menuFont, + wrapX: true, + wrapY: true + }, + mainMenuItemText: "ITEM", + mainMenuSpellText: "SPELL", + mainMenuCapsuleText: "CAPSULE", + mainMenuEquipmentText: "EQUIP", + mainMenuStatusText: "STATUS", + mainMenuChangeText: "CHANGE", + mainMenuConfigText: "CONFIG", + mainMenuScenarioText: "SCENARIO", + mainMenuTimeText: "TIME", + mainMenuGoldText: "GOLD", + heroCursor: Sprite { + image: :"hero-cursor.png", + size: <64, 16> + }, + heroCursorBlinkTime: 532, + noEquipmentText: "No equip", + shoulderNav: Sprite { + image: :"shoulder-nav.png", + size: <160, 16> + }, + atpLabel: "ATP", + dfpLabel: "DFP", + strLabel: "STR", + aglLabel: "AGL", + intLabel: "INT", + gutLabel: "GUT", + mgrLabel: "MGR", + ipLabel: "IP", + experienceLabel: "NOW EXP", + nextLevelLabel: "NEXT LEVEL", + statusMenu: MenuProperties { + cols: 2, + rows: 1, + charsPerEntry: 6, + colGap: 16, + cursor: menuCursor, + font: menuFont, + wrapX: true + }, + nextLabel: "NEXT", + returnLabel: "RETURN", + itemMenu: MenuProperties { + cols: 3, + rows: 1, + charsPerEntry: 5, + rowGap: 8, + colGap: 16, + cursor: menuCursor, + selectedCursor: menuActiveCursor, + font: menuFont, + wrapX: true, + wrapY: true + }, + itemMenuUseText: "USE", + itemMenuSortText: "SORT", + itemMenuDropText: "DROP", + inventoryMenu: MenuProperties { + cols: 1, + rows: 6, + charsPerEntry: 13, + rowGap: 8, + cursor: menuCursor, + selectedCursor: menuActiveCursor, + font: menuFont, + disabledFont: menuInactiveFont, + iconSpace: 16, + charsPerNumber: 2, + delimiter: ":" + }, + spellMenu: MenuProperties { + cols: 2, + rows: 6, + charsPerEntry: 8, + rowGap: 8, + colGap: 48, + cursor: menuCursor, + selectedCursor: menuActiveCursor, + font: menuFont, + disabledFont: menuInactiveFont, + charsPerNumber: 2, + delimiter: ":" + }, + equipmentActionMenu: MenuProperties { + cols: 1, + rows: 5, + charsPerEntry: 10, + rowGap: 8, + cursor: menuCursor, + selectedCursor: menuActiveCursor, + font: menuFont + }, + equipmentMenu: MenuProperties { + cols: 1, + rows: 6, + charsPerEntry: 12, + rowGap: 16, + cursor: menuCursor, + selectedCursor: menuActiveCursor, + font: normalFont, + iconSpace: 16, + wrapY: true + }, + equipMenuEquipLabel: "EQUIP", + equipMenuStrongestLabel: "STRONGEST", + equipMenuRemoveLabel: "REMOVE", + equipMenuRemoveAllLabel: "REMOVE ALL", + equipMenuDropLabel: "DROP", + configMenu: MenuProperties { + cols: 1, + rows: 4, + charsPerEntry: 8, + rowGap: 32, + cursor: menuCursor, + font: menuFont, + wrapY: true + }, + configMessageSpeedLabel: "MESSAGE\n SPEED", + configMessageSpeedFast: "FAST", + configMessageSpeedNormal: "NORMAL", + configMessageSpeedSlow: "SLOW", + configBattleCursorLabel: "BATTLE\n CURSOR", + configStatusCursorLabel: "STATUS\n CURSOR", + configCursorClear: "CLEAR", + configCursorMemory: "MEMORY", + configMusicLabel: "MUSIC", + configMusicStereo: "STEREO", + configMusicMono: "MONO", + scenarioMenu: MenuProperties { + cols: 1, + rows: 6, + charsPerEntry: 14, + rowGap: 8, + cursor: menuCursor, + font: menuFont + }, + scenarioMenuHeadline: "SCENARIO ITEM" +}