From 4e1f50035e860a00636ca5d804c267119df99601 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Sun, 11 Aug 2013 04:09:45 +0200 Subject: Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenu --- src/guiEngine.h | 78 ++++++++++++++++----------------------------------------- 1 file changed, 21 insertions(+), 57 deletions(-) (limited to 'src/guiEngine.h') diff --git a/src/guiEngine.h b/src/guiEngine.h index 2f96b0b1c..3987b52c7 100644 --- a/src/guiEngine.h +++ b/src/guiEngine.h @@ -26,7 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes.h" #include "modalMenu.h" #include "clouds.h" -#include "guiLuaApi.h" #include "guiFormSpecMenu.h" #include "sound.h" @@ -50,6 +49,7 @@ typedef enum { /* forward declarations */ /******************************************************************************/ class GUIEngine; +class MainMenuScripting; struct MainMenuData; struct SimpleSoundSpec; @@ -86,35 +86,17 @@ class MenuMusicFetcher: public OnDemandSoundFetcher { std::set m_fetched; public: - void fetchSounds(const std::string &name, std::set &dst_paths, - std::set &dst_datas) - { - if(m_fetched.count(name)) - return; - m_fetched.insert(name); - std::string base; - base = porting::path_share + DIR_DELIM + "sounds"; - dst_paths.insert(base + DIR_DELIM + name + ".ogg"); - int i; - for(i=0; i<10; i++) - dst_paths.insert(base + DIR_DELIM + name + "."+itos(i)+".ogg"); - base = porting::path_user + DIR_DELIM + "sounds"; - dst_paths.insert(base + DIR_DELIM + name + ".ogg"); - for(i=0; i<10; i++) - dst_paths.insert(base + DIR_DELIM + name + "."+itos(i)+".ogg"); - } + std::set &dst_datas); }; /** implementation of main menu based uppon formspecs */ class GUIEngine { -public: - /** TextDestGuiEngine needs to transfer data to engine */ - friend class TextDestGuiEngine; - /** guiLuaApi is used to initialize contained stack */ - friend class guiLuaApi; + /** grant ModApiMainMenu access to private members */ + friend class ModApiMainMenu; +public: /** * default constructor * @param dev device to draw at @@ -132,20 +114,12 @@ public: /** default destructor */ virtual ~GUIEngine(); - s32 playSound(SimpleSoundSpec spec, bool looped); - void stopSound(s32 handle); - -protected: /** - * process field data recieved from formspec - * @param fields data in field format + * return MainMenuScripting interface */ - void handleButtons(std::map fields); - /** - * process events received from formspec - * @param text events in textual form - */ - void handleEvent(std::string text); + MainMenuScripting* getScriptIface() { + return m_script; + } /** * return dir of current menuscript @@ -156,7 +130,10 @@ protected: private: - /* run main menu loop */ + /** find and run the main menu script */ + bool loadMainMenuScript(); + + /** run main menu loop */ void run(); /** handler to limit frame rate within main menu */ @@ -185,27 +162,8 @@ private: /** variable used to abort menu and return back to main game handling */ bool m_startgame; - /** - * initialize lua stack - * @param L stack to initialize - */ - void initalize_api(lua_State * L); - - /** - * run a lua script - * @param script full path to script to run - */ - bool runScript(std::string script); - - /** - * script error handler to process errors within lua - */ - void scriptError(const char *fmt, ...); - - /** lua stack */ - lua_State* m_engineluastack; - /** lua internal stack number of error handler*/ - int m_luaerrorhandler; + /** scripting interface */ + MainMenuScripting* m_script; /** script basefolder */ std::string m_scriptdir; @@ -284,6 +242,12 @@ private: /** data used to draw clouds */ clouddata m_cloud; + /** start playing a sound and return handle */ + s32 playSound(SimpleSoundSpec spec, bool looped); + /** stop playing a sound started with playSound() */ + void stopSound(s32 handle); + + }; -- cgit v1.2.3