Added input to apps/mygui_dev/

pull/7/head
Nicolay Korslund 15 years ago
parent 13d3f9c87e
commit 4eb2863db4

@ -101,10 +101,10 @@ set(OENGINE_OGRE
${LIBDIR}/openengine/ogre/mouselook.cpp
)
set(OENGINE_GUI
# ${LIBDIR}/openengine/gui/events.cpp
${LIBDIR}/openengine/gui/events.cpp
${LIBDIR}/openengine/gui/manager.cpp
) # Not yet included in main executable
set(OENGINE_ALL ${OENGINE_OGRE})
)
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI})
source_group(libs\\openengine FILES ${OENGINE_ALL})
set(OPENMW_LIBS ${MANGLE_ALL} ${OENGINE_ALL})

@ -3,6 +3,7 @@ add_executable(mygui_test
${BSA} ${BSA_HEADER}
${OENGINE_OGRE}
${OENGINE_GUI}
${MANGLE_INPUT}
)
target_link_libraries(mygui_test
${OGRE_LIBRARIES}

@ -2,8 +2,11 @@
using namespace std;
#include <openengine/gui/manager.hpp>
#include <openengine/gui/events.hpp>
#include <openengine/ogre/renderer.hpp>
#include <mangle/input/servers/ois_driver.hpp>
#include <components/mw_gui/mw_layouts.hpp>
#include <components/bsa/bsa_archive.hpp>
@ -12,29 +15,24 @@ using namespace std;
#include <OgreFrameListener.h>
#include <OgreRoot.h>
#include <OIS/OISKeyboard.h>
// Frame listener
struct Listener : public Ogre::FrameListener
{
bool exit;
float total;
int step;
Listener() : exit(false), total(0.0), step(0) {}
Mangle::Input::Driver *input;
Listener() : exit(false) {}
bool frameStarted(const Ogre::FrameEvent &evt)
{
total += evt.timeSinceLastFrame;
// Countdown to exit
const int MAX = 4;
if(total >= step)
{
step++;
if(step<MAX)
cout << "Exit in " << (MAX-step) << endl;
else
exit = true;
}
if(input)
input->capture();
if(input->isDown(OIS::KC_ESCAPE))
exit = true;
return !exit;
}
@ -59,6 +57,10 @@ int main()
// there
addBSA("data/Morrowind.bsa");
cout << "Setting up input with OIS\n";
Mangle::Input::OISDriver input(ogre.getWindow());
listener.input = &input;
// Make sure you load the data paths BEFORE you initialize the
// GUI. MyGUI depends on finding core.xml in resources/mygui/.
cout << "Setting up MyGUI\n";
@ -67,6 +69,10 @@ int main()
int w = ogre.getWindow()->getWidth();
int h = ogre.getWindow()->getHeight();
cout << "Connecting to input\n";
OEngine::GUI::EventInjector *evt = new OEngine::GUI::EventInjector(gui.getGui());
input.setEvent(Mangle::Input::EventPtr(evt));
cout << "Setting up the window layouts\n";
MWGUI::HUD hud(w,h);
MWGUI::MapWindow map;
@ -79,24 +85,10 @@ int main()
stats.setVisible(true);
cout << "Starting rendering loop\n";
cout << "PRESS ESCAPE TO EXIT\n";
ogre.start();
ogre.screenshot("mygui_test.png");
cout << "Done.\n";
return 0;
}
/// Old D function
/*
extern "C" MyGUI::WidgetPtr gui_createText(const char *skin,
int32_t x, int32_t y,
int32_t w, int32_t h,
const char *layer)
{
return mGUI->createWidget<MyGUI::StaticText>
(skin,
x,y,w,h,
MyGUI::ALIGN_LEFT | MyGUI::ALIGN_TOP,
layer);
}
*/

@ -1 +1 @@
Subproject commit 9f21081c13f70bc41e20b50c19ed2dac9b458833
Subproject commit c7b179d6546688208528c8eef681d42b7c1ec7be

@ -1 +1 @@
Subproject commit 69a56e867749944dc0e86b9ef5c54bac4339b454
Subproject commit fedb1a80256a093511075aeb88408c7c56a136ce
Loading…
Cancel
Save