kart selection screen is now shown when you press new game, and a (black) model preview appears

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3279 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-03-19 01:52:35 +00:00
parent a6f6c3d6ab
commit e9b4109c9b
6 changed files with 69 additions and 11 deletions

View File

@ -6,7 +6,7 @@
<label width="100%" height="25" text="(P1) Keyboard 1" align="center" text_align="center" />
<spinner id="player" width="40%" height="25" min_value="0" max_value="8" align="center"/>
<button text="TODO" width="40%" proportion="3" align="center"/>
<model id="modelview" width="40%" proportion="3" align="center"/>
<label width="100%" height="25" text="Wilber" align="center" text_align="center" />
<ribbon_grid id="karts" proportion="2" width="100%" align="center" child_width="80" child_height="80"/>

View File

@ -32,6 +32,8 @@ void parseScreenFileDiv(irr::io::IrrXMLReader* xml, ptr_vector<Widget>& append_t
{
WidgetType type;
std::cout << "node: " << xml->getNodeName() << std::endl;
if (!strcmp("div", xml->getNodeName()))
{
type = WTYPE_DIV;
@ -87,11 +89,6 @@ void parseScreenFileDiv(irr::io::IrrXMLReader* xml, ptr_vector<Widget>& append_t
type = WTYPE_LABEL;
append_to.push_back(new LabelWidget());
}
else if (!strcmp("model", xml->getNodeName()))
{
type = WTYPE_MODEL;
append_to.push_back(new Widget()); // TODO
}
else if (!strcmp("spacer", xml->getNodeName()))
{
type = WTYPE_NONE;
@ -102,6 +99,12 @@ void parseScreenFileDiv(irr::io::IrrXMLReader* xml, ptr_vector<Widget>& append_t
type = WTYPE_RIBBON_GRID;
append_to.push_back(new RibbonGridWidget());
}
else if (!strcmp("model", xml->getNodeName()))
{
type = WTYPE_MODEL_VIEW;
append_to.push_back(new ModelViewWidget());
std::cout << "creating a ModelViewWidget\n";
}
else
{
std::cerr << "/!\\ Warning /!\\ : unknown tag found in STK GUI file : '" << xml->getNodeName() << "'" << std::endl;

View File

@ -8,6 +8,8 @@
#include "race_manager.hpp"
#include "network/network_manager.hpp"
#include "main_loop.hpp"
#include "karts/kart_properties_manager.hpp"
#include "karts/kart.hpp"
#include <vector>
@ -35,11 +37,11 @@ namespace StateManager
{
std::cout << "event!! " << name.c_str() << std::endl;
// --- main menu
if(name == "menu_toprow")
{
std::string selection = ((GUIEngine::RibbonWidget*)widget)->getSelectionName().c_str();
if(selection == "new") GUIEngine::switchToScreen("racesetup.stkgui");
if(selection == "challenges")
if(selection == "new")
{
GUIEngine::switchToScreen("karts.stkgui");
GUIEngine::RibbonGridWidget* w = dynamic_cast<GUIEngine::RibbonGridWidget*>(GUIEngine::getCurrentScreen()->getWidget("karts"));
@ -56,12 +58,26 @@ namespace StateManager
w->addItem("Mozilla","k8","gnu.png");
w->updateItemDisplay();
GUIEngine::SpinnerWidget* w2 = dynamic_cast<GUIEngine::SpinnerWidget*>(GUIEngine::getCurrentScreen()->getWidget("player"));
GUIEngine::SpinnerWidget* w2 = dynamic_cast<GUIEngine::SpinnerWidget*>
(GUIEngine::getCurrentScreen()->getWidget("player"));
assert( w2 != NULL );
w2->addLabel("Hiker");
w2->addLabel("Auria");
w2->addLabel("Conso");
w2->addLabel("MiniBjorn");
GUIEngine::ModelViewWidget* w3 = dynamic_cast<GUIEngine::ModelViewWidget*>
(GUIEngine::getCurrentScreen()->getWidget("modelview"));
assert( w3 != NULL );
// set kart model
IMesh* mesh = kart_properties_manager->getKart("tux")->getKartModel()->getModel();
SAnimatedMesh* test = new SAnimatedMesh(); // FIXME - memory management
test->addMesh(mesh);
test->setMaterialFlag(EMF_LIGHTING , false);
w3->setModel(test);
}
}
if(name == "menu_bottomrow")
@ -74,6 +90,13 @@ namespace StateManager
}
}
// -- kart selection screen
if(name == "karts")
{
GUIEngine::switchToScreen("racesetup.stkgui");
}
// -- race setup screen
if(name == "gamemode")
{
GUIEngine::RibbonWidget* w = dynamic_cast<GUIEngine::RibbonWidget*>(widget);
@ -83,6 +106,7 @@ namespace StateManager
}
}
// -- track seelction screen
if(name == "tracks")
{
GUIEngine::RibbonGridWidget* w2 = dynamic_cast<GUIEngine::RibbonGridWidget*>(widget);

View File

@ -792,6 +792,7 @@ bool RibbonGridWidget::transmitEvent(Widget* w, std::string& originator)
// if we got there, must be a ribbon itself. in this case we can just transmit the event directly
return true;
}
// -----------------------------------------------------------------------------
void RibbonGridWidget::scroll(const int x_delta)
{
m_scroll_offset += x_delta;
@ -951,4 +952,26 @@ RibbonWidget* RibbonGridWidget::getSelectedRibbon() const
}
return NULL;
}
#if 0
#pragma mark -
#pragma mark Ribbon Grid Widget
#endif
// -----------------------------------------------------------------------------
void ModelViewWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
stringw message = m_properties[PROP_TEXT].c_str();
m_element = GUIEngine::getGUIEnv()->addMeshViewer(widget_size, NULL, ++id_counter);
id = m_element->getID();
m_element->setTabOrder(id);
m_element->setTabGroup(false);
}
// -----------------------------------------------------------------------------
void ModelViewWidget::setModel(SAnimatedMesh* mesh)
{
((IGUIMeshViewer*)m_element)->setMesh( mesh );
}

View File

@ -21,10 +21,10 @@ namespace GUIEngine
WTYPE_ICON_BUTTON,
WTYPE_CHECKBOX,
WTYPE_LABEL,
WTYPE_MODEL,
WTYPE_SPACER,
WTYPE_DIV,
WTYPE_RIBBON_GRID
WTYPE_RIBBON_GRID,
WTYPE_MODEL_VIEW
};
enum Property
@ -284,5 +284,12 @@ namespace GUIEngine
const std::string& getSelectionName();
};
class ModelViewWidget : public Widget
{
public:
void add();
void setModel(SAnimatedMesh* mesh);
};
}
#endif

View File

@ -117,6 +117,7 @@ public:
void loadModels(const std::string &kart_ident);
#ifdef HAVE_IRRLICHT
void attachModel(scene::ISceneNode **node);
scene::IMesh* getModel() const { return m_mesh; }
#else
ssgTransform *getRoot() const { return m_root; }
#endif