Get the network preferences from the mock prefs implementation

This commit is contained in:
simon.kagstrom 2010-01-01 09:30:05 +00:00
parent 16d306bae4
commit 28aea581e7
5 changed files with 35 additions and 19 deletions

View File

@ -4,7 +4,7 @@ OBJS=menu.oo main.oo utils.oo gui.oo dialogue_box.oo menu_messages.oo \
all: menu
%.oo: %.cpp
g++ -Wall -g -c `sdl-config --cflags` -o $@ $<
g++ -Imocks -Wall -g -c `sdl-config --cflags` -o $@ $<
menu.oo: menu.cpp menu.hh utils.hh font.hh widget.hh Makefile
@ -13,7 +13,7 @@ widget.oo: widget.cpp widget.hh
gui.oo: gui.cpp gui.hh Makefile font.hh menu.hh sdl_ttf_font.hh \
dialogue_box.hh help_box.hh main_menu.cpp disc_menu.cpp \
file_browser.hh timer.hh game_info.hh widget.hh options_menu.cpp \
network_menu.cpp
network_menu.cpp mocks/Prefs.h
virtual_keyboard.oo: virtual_keyboard.hh virtual_keyboard.cpp widget.hh listener.hh

View File

@ -52,6 +52,8 @@ void GuiView::viewPopCallback()
Gui::Gui()
{
this->np = NULL;
this->focus = NULL;
this->bg_left = NULL;
@ -255,10 +257,14 @@ void Gui::draw(SDL_Surface *where)
void Gui::activate()
{
this->is_active = true;
/* FIXME! TMP! TMP! */
this->np = new Prefs();
}
void Gui::deActivate()
{
/* FIXME! TMP! TMP! */
delete this->np;
this->is_active = false;
}

6
gui.hh
View File

@ -8,6 +8,9 @@
#include "timer.hh"
#include "gui_view.hh"
/* Frodo stuff */
#include <Prefs.h>
class MainView;
class DialogueBox;
class DiscView;
@ -91,6 +94,9 @@ public:
const char *theme_base_path;
const char *game_base_path;
/* New preferences */
Prefs *np;
/* Singleton */
static void init();
static Gui *gui;

View File

@ -1,8 +1,18 @@
#ifndef __MOCK_PREFS_HH__
#define __MOCK_PREFS_HH__
#include <string.h>
class Prefs
{
public:
Prefs()
{
strcpy(this->NetworkName, "Unset name");
strcpy(this->NetworkServer, "play.c64-network.org");
this->NetworkPort = 46214;
}
char NetworkName[32];
char NetworkServer[128];
int NetworkPort;

View File

@ -11,7 +11,8 @@ public:
NetworkMenu(Font *font, HelpBox *help) : Menu(font)
{
this->help = help;
this->updateMessages();
memset(this->messages, 0, sizeof(this->messages));
memset(this->strs, 0, sizeof(this->strs));
}
~NetworkMenu()
@ -23,19 +24,7 @@ public:
printf("option entry %d selected: %s\n", which, this->pp_msgs[which]);
switch (which)
{
case 0: /* Insert disc */
break;
case 2: /* Load/save states */
break;
case 4: /* Keyboard */
break;
case 7: /* Reset the C64 */
break;
case 8: /* Networking */
break;
case 9: /* Options */
break;
case 10: /* Help */
default:
break;
}
}
@ -55,11 +44,11 @@ private:
{
memset(this->strs, 0, sizeof(this->strs));
snprintf(this->strs[0], sizeof(this->strs[0]) - 1, "Set username (%s)",
"Vobb"); // FIXME!
Gui::gui->np->NetworkName);
snprintf(this->strs[1], sizeof(this->strs[1]) - 1, "Server (%s)",
"play.c64-network.org"); // FIXME!
Gui::gui->np->NetworkServer);
snprintf(this->strs[2], sizeof(this->strs[2]) - 1, "Server port (%d)",
46214); // FIXME!
Gui::gui->np->NetworkPort);
this->messages[0] = this->strs[0];
this->messages[1] = this->strs[1];
@ -114,6 +103,11 @@ public:
this->menu->pushEvent(ev);
}
void viewPushCallback()
{
this->menu->updateMessages();
}
void draw(SDL_Surface *where)
{
SDL_Rect dst;