Skip to content

Commit

Permalink
Main menu rewrite as imgui window
Browse files Browse the repository at this point in the history
  • Loading branch information
xythobuz committed Mar 13, 2015
1 parent ae5868b commit 8ebbd70
Show file tree
Hide file tree
Showing 25 changed files with 3,143 additions and 542 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>

[ 20140312 ]
* Now including imguifilesystem dependency
* Completely re-wrote Main menu, now reading TOMBPC.DAT scripts
* Main menu is now just a full-screen ImGui window

[ 20140310 ]
* Tried to fix moveable loading. Fixed TR1 angle parser, but still not working better.

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,7 @@ See the respective files in `cmake` for their licensing.

The [clibs/commander](https://github.com/clibs/commander) dependency is Copyright (c) 2012 TJ Holowaychuk (tj@vision-media.ca) and licensed under the [MIT License](http://opensource.org/licenses/MIT).

The included GUI lib, [imgui](https://github.com/ocornut/imgui/) is Copyright (c) 2014 Omar Cornut. See src/deps/imgui/LICENSE for more informations about the MIT license used.
The included GUI lib, [imgui](https://github.com/ocornut/imgui/) is Copyright (c) 2014 Omar Cornut. See src/deps/imgui/LICENSE for more informations about the MIT license used.

Also included is the imgui addon [imguifilesystem by Flix01](https://gist.github.com/Flix01/f34b5efa91e50a241c1b).

3 changes: 1 addition & 2 deletions include/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#define _GAME_H_

#include <string>
#include <vector>

#include "Entity.h"

Expand All @@ -18,7 +17,7 @@ class Game {
static void destroy();

static bool isLoaded() { return mLoaded; }
static int loadLevel(const char* level);
static int loadLevel(std::string level);

static void handleAction(ActionEvents action, bool isFinished);
static void handleMouseMotion(int xrel, int yrel, int xabs, int yabs);
Expand Down
59 changes: 16 additions & 43 deletions include/Menu.h
Original file line number Diff line number Diff line change
@@ -1,64 +1,37 @@
/*!
* \file include/Menu.h
* \brief Menu 'overlay' interface
* \brief Main Menu
*
* \author xythobuz
*/

#ifndef _MENU_H_
#define _MENU_H_

#include <functional>
#include <vector>

#include "Script.h"
#include "utils/Folder.h"

class Menu {
public:
static int initialize();
static void shutdown();
static void display();

virtual ~Menu() { }

virtual int initialize() = 0;

virtual void display() = 0;

virtual void handleKeyboard(KeyboardButton key, bool pressed) = 0;

virtual void handleMouseClick(unsigned int x, unsigned int y,
KeyboardButton button, bool released) = 0;

virtual void handleMouseScroll(int xrel, int yrel) = 0;

bool isVisible() { return visible; }

void setVisible(bool v) { visible = v; }
static bool isVisible() { return visible; }
static void setVisible(bool v) { visible = v; }

static const glm::vec4 textColor;
static const glm::vec4 selectedColor;

protected:

virtual void showDialog(std::string msg, std::string btn1, std::string btn2 = "",
std::function<int (bool state)> callback = std::function<int (bool)>());

virtual void ackDialog();

virtual bool handleKeyboardDialog(KeyboardButton key, bool pressed);

virtual bool handleMouseClickDialog(unsigned int x, unsigned int y,
KeyboardButton button, bool released);

virtual bool handleMouseScrollDialog(int xrel, int yrel);

virtual void displayDialog();

bool dialogState;
std::string dialogText;
std::string dialogButton1;
std::string dialogButton2;
std::function<int (bool state)> dialogFunction;

bool visible;
private:
static bool visible;
static Folder* mapFolder;
static std::vector<Script> scripts;
static std::vector<Folder> paths;
static std::vector<int> images;
};

Menu& getMenu();

#endif

52 changes: 0 additions & 52 deletions include/MenuFolder.h

This file was deleted.

6 changes: 4 additions & 2 deletions include/Script.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ class Script {
} ScriptItem;

Script();
~Script();

int load(const char* file);
int load(std::string file);

unsigned int levelCount();
std::string getLevelName(unsigned int i);
Expand Down Expand Up @@ -124,6 +123,9 @@ class Script {
void registerScriptHandler(ScriptOpCode op, std::function<int (bool, uint16_t)> func);
int runScript(unsigned int level);

std::string getDescription() { return description; }
std::string getLanguage();

private:

typedef enum {
Expand Down
6 changes: 6 additions & 0 deletions include/utils/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ std::string expandHomeDirectory(std::string s);

bool stringEndsWith(std::string s, std::string suffix, bool casesensitive = false);

std::string removeLastPathElement(std::string s);

std::string getLastPathElement(std::string s);

std::string convertPathDelimiter(std::string s);

#endif

1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ set (SRCS ${SRCS} "Game.cpp" "../include/Game.h")
set (SRCS ${SRCS} "Log.cpp" "../include/Log.h")
set (SRCS ${SRCS} "main.cpp")
set (SRCS ${SRCS} "Menu.cpp" "../include/Menu.h")
set (SRCS ${SRCS} "MenuFolder.cpp" "../include/MenuFolder.h")
set (SRCS ${SRCS} "Mesh.cpp" "../include/Mesh.h")
set (SRCS ${SRCS} "Render.cpp" "../include/Render.h")
set (SRCS ${SRCS} "Room.cpp" "../include/Room.h")
Expand Down
6 changes: 3 additions & 3 deletions src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Game.h"
#include "loader/Loader.h"
#include "Log.h"
#include "Menu.h"
#include "Render.h"
#include "SoundManager.h"
#include "TextureManager.h"
Expand All @@ -37,7 +38,7 @@ void Game::destroy() {
getWorld().destroy();
}

int Game::loadLevel(const char* level) {
int Game::loadLevel(std::string level) {
destroy();

Log::get(LOG_INFO) << "Loading " << level << Log::endl;
Expand All @@ -63,11 +64,10 @@ int Game::loadLevel(const char* level) {

mLoaded = true;
Render::setMode(RenderMode::Texture);
Menu::setVisible(false);

if (mLara == -1) {
Log::get(LOG_WARNING) << "Can't find Lara entity in level?!" << Log::endl;
Console::setVisible(true);
UI::setVisible(true);
} else {
Camera::setPosition(glm::vec3(getLara().getPosition().x,
getLara().getPosition().y - 1024.0f,
Expand Down
Loading

0 comments on commit 8ebbd70

Please sign in to comment.