mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 19:39:24 +01:00
Implement network region setting (but still not on the network end)
This commit is contained in:
parent
37ca5e562b
commit
65f0844cae
@ -22,6 +22,20 @@
|
|||||||
#define SCREENSHOT_X (DISPLAY_X / SCREENSHOT_FACTOR)
|
#define SCREENSHOT_X (DISPLAY_X / SCREENSHOT_FACTOR)
|
||||||
#define SCREENSHOT_Y (DISPLAY_Y / SCREENSHOT_FACTOR)
|
#define SCREENSHOT_Y (DISPLAY_Y / SCREENSHOT_FACTOR)
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
REGION_UNKNOWN = 0,
|
||||||
|
REGION_EUROPE = 1,
|
||||||
|
REGION_AFRICA = 2,
|
||||||
|
REGION_NORTH_AMERICA = 3,
|
||||||
|
REGION_SOUTH_AMERICA = 4,
|
||||||
|
REGION_MIDDLE_EAST = 5,
|
||||||
|
REGION_SOUTH_ASIA = 6,
|
||||||
|
REGION_EAST_ASIA = 7,
|
||||||
|
REGION_OCEANIA = 8,
|
||||||
|
REGION_ANTARTICA = 9,
|
||||||
|
} network_region_t;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
/* Connection-related messages */
|
/* Connection-related messages */
|
||||||
|
@ -104,6 +104,7 @@ Prefs::Prefs()
|
|||||||
snprintf(this->NetworkName, 32, "Unset name");
|
snprintf(this->NetworkName, 32, "Unset name");
|
||||||
snprintf(this->NetworkServer, 64, "play.c64-network.org");
|
snprintf(this->NetworkServer, 64, "play.c64-network.org");
|
||||||
this->NetworkPort = 46215; // FIXME! Set back to 46214 when ready
|
this->NetworkPort = 46215; // FIXME! Set back to 46214 when ready
|
||||||
|
this->NetworkRegion = REGION_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -226,6 +227,7 @@ bool Prefs::operator==(const Prefs &rhs) const
|
|||||||
#endif
|
#endif
|
||||||
&& this->NetworkKey == rhs.NetworkKey
|
&& this->NetworkKey == rhs.NetworkKey
|
||||||
&& this->NetworkPort == rhs.NetworkPort
|
&& this->NetworkPort == rhs.NetworkPort
|
||||||
|
&& this->NetworkRegion == rhs.NetworkRegion
|
||||||
&& strcmp(this->NetworkServer, rhs.NetworkServer) == 0
|
&& strcmp(this->NetworkServer, rhs.NetworkServer) == 0
|
||||||
&& strcmp(this->NetworkName, rhs.NetworkName) == 0
|
&& strcmp(this->NetworkName, rhs.NetworkName) == 0
|
||||||
&& this->NetworkAvatar == rhs.NetworkAvatar
|
&& this->NetworkAvatar == rhs.NetworkAvatar
|
||||||
@ -392,11 +394,12 @@ void Prefs::Load(const char *filename)
|
|||||||
strcpy(NetworkName, value);
|
strcpy(NetworkName, value);
|
||||||
else if (!strcmp(keyword, "NetworkServer"))
|
else if (!strcmp(keyword, "NetworkServer"))
|
||||||
strcpy(NetworkServer, value);
|
strcpy(NetworkServer, value);
|
||||||
#warning take back in real release
|
else if (!strcmp(keyword, "NetworkPort"))
|
||||||
// else if (!strcmp(keyword, "NetworkPort"))
|
NetworkPort = atoi(value);
|
||||||
// NetworkPort = atoi(value);
|
|
||||||
else if (!strcmp(keyword, "NetworkName"))
|
else if (!strcmp(keyword, "NetworkName"))
|
||||||
strcpy(NetworkName, value);
|
strcpy(NetworkName, value);
|
||||||
|
else if (!strcmp(keyword, "NetworkRegion"))
|
||||||
|
NetworkRegion = atoi(value);
|
||||||
else if (!strcmp(keyword, "NetworkAvatar"))
|
else if (!strcmp(keyword, "NetworkAvatar"))
|
||||||
NetworkAvatar = atoi(value);
|
NetworkAvatar = atoi(value);
|
||||||
}
|
}
|
||||||
@ -497,6 +500,7 @@ bool Prefs::Save(const char *filename)
|
|||||||
fprintf(file, "NetworkName = %s\n", NetworkName);
|
fprintf(file, "NetworkName = %s\n", NetworkName);
|
||||||
fprintf(file, "NetworkServer = %s\n", NetworkServer);
|
fprintf(file, "NetworkServer = %s\n", NetworkServer);
|
||||||
fprintf(file, "NetworkPort = %d\n", NetworkPort);
|
fprintf(file, "NetworkPort = %d\n", NetworkPort);
|
||||||
|
fprintf(file, "NetworkRegion = %d\n", NetworkRegion);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
ThePrefsOnDisk = *this;
|
ThePrefsOnDisk = *this;
|
||||||
return true;
|
return true;
|
||||||
|
@ -178,6 +178,7 @@ private:
|
|||||||
|
|
||||||
char NetworkName[32];
|
char NetworkName[32];
|
||||||
char NetworkServer[64];
|
char NetworkServer[64];
|
||||||
|
int NetworkRegion;
|
||||||
int NetworkPort;
|
int NetworkPort;
|
||||||
|
|
||||||
int NetworkKey;
|
int NetworkKey;
|
||||||
|
@ -42,6 +42,7 @@ static const char *get_theme_path(const char *dir, const char *what)
|
|||||||
#include "bind_keys_menu.cpp"
|
#include "bind_keys_menu.cpp"
|
||||||
#include "theme_menu.cpp"
|
#include "theme_menu.cpp"
|
||||||
#include "options_menu.cpp"
|
#include "options_menu.cpp"
|
||||||
|
#include "network_region_menu.cpp"
|
||||||
#include "network_menu.cpp"
|
#include "network_menu.cpp"
|
||||||
#include "game_info_menu.cpp"
|
#include "game_info_menu.cpp"
|
||||||
#include "main_menu.cpp"
|
#include "main_menu.cpp"
|
||||||
@ -112,6 +113,7 @@ Gui::Gui()
|
|||||||
this->giv = NULL;
|
this->giv = NULL;
|
||||||
this->bkv = NULL;
|
this->bkv = NULL;
|
||||||
this->nuv = NULL;
|
this->nuv = NULL;
|
||||||
|
this->nrv = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gui::~Gui()
|
Gui::~Gui()
|
||||||
@ -125,6 +127,7 @@ Gui::~Gui()
|
|||||||
delete this->giv;
|
delete this->giv;
|
||||||
delete this->bkv;
|
delete this->bkv;
|
||||||
delete this->nuv;
|
delete this->nuv;
|
||||||
|
delete this->nrv;
|
||||||
|
|
||||||
delete this->cur_gameInfo;
|
delete this->cur_gameInfo;
|
||||||
delete this->timerController;
|
delete this->timerController;
|
||||||
@ -235,6 +238,7 @@ bool Gui::setTheme(const char *path)
|
|||||||
this->bkv = new BindKeysView();
|
this->bkv = new BindKeysView();
|
||||||
this->giv = new GameInfoView();
|
this->giv = new GameInfoView();
|
||||||
this->nuv = new NetworkUserView();
|
this->nuv = new NetworkUserView();
|
||||||
|
this->nrv = new NetworkRegionView();
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualKeyboard::kbd->updateTheme();
|
VirtualKeyboard::kbd->updateTheme();
|
||||||
@ -305,6 +309,9 @@ GuiView *Gui::popView()
|
|||||||
|
|
||||||
this->views = (GuiView**)xrealloc(this->views,
|
this->views = (GuiView**)xrealloc(this->views,
|
||||||
sizeof(GuiView*) * this->n_views);
|
sizeof(GuiView*) * this->n_views);
|
||||||
|
if (this->peekView())
|
||||||
|
this->peekView()->viewPushCallback();
|
||||||
|
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ class NetworkView;
|
|||||||
class ThemeView;
|
class ThemeView;
|
||||||
class GameInfoView;
|
class GameInfoView;
|
||||||
class NetworkUserView;
|
class NetworkUserView;
|
||||||
|
class NetworkRegionView;
|
||||||
|
|
||||||
class VirtualKeyboard;
|
class VirtualKeyboard;
|
||||||
|
|
||||||
@ -111,6 +112,7 @@ public:
|
|||||||
ThemeView *tv;
|
ThemeView *tv;
|
||||||
BindKeysView *bkv;
|
BindKeysView *bkv;
|
||||||
NetworkUserView *nuv;
|
NetworkUserView *nuv;
|
||||||
|
NetworkRegionView *nrv;
|
||||||
|
|
||||||
GuiView **views;
|
GuiView **views;
|
||||||
int n_views;
|
int n_views;
|
||||||
|
@ -62,10 +62,12 @@ public:
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
|
||||||
VirtualKeyboard::kbd->activate();
|
VirtualKeyboard::kbd->activate();
|
||||||
VirtualKeyboard::kbd->registerListener(this);
|
VirtualKeyboard::kbd->registerListener(this);
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
Gui::gui->pushView(Gui::gui->nrv);
|
||||||
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if ( strncmp(Gui::gui->np->NetworkName, "Unset", strlen("Unset")) == 0)
|
if ( strncmp(Gui::gui->np->NetworkName, "Unset", strlen("Unset")) == 0)
|
||||||
Gui::gui->pushDialogueBox(new DialogueBox(network_unset_name_dlg));
|
Gui::gui->pushDialogueBox(new DialogueBox(network_unset_name_dlg));
|
||||||
@ -104,8 +106,8 @@ private:
|
|||||||
Gui::gui->np->NetworkName);
|
Gui::gui->np->NetworkName);
|
||||||
snprintf(this->strs[1], sizeof(this->strs[1]) - 1, "Server (%s)",
|
snprintf(this->strs[1], sizeof(this->strs[1]) - 1, "Server (%s)",
|
||||||
Gui::gui->np->NetworkServer);
|
Gui::gui->np->NetworkServer);
|
||||||
snprintf(this->strs[2], sizeof(this->strs[2]) - 1, "Server port (%d)",
|
snprintf(this->strs[2], sizeof(this->strs[2]) - 1, "Set region (%s)",
|
||||||
Gui::gui->np->NetworkPort);
|
region_to_str(Gui::gui->np->NetworkRegion));
|
||||||
|
|
||||||
this->messages[0] = this->strs[0];
|
this->messages[0] = this->strs[0];
|
||||||
this->messages[1] = this->strs[1];
|
this->messages[1] = this->strs[1];
|
||||||
|
99
Src/gui/network_region_menu.cpp
Normal file
99
Src/gui/network_region_menu.cpp
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#include "gui.hh"
|
||||||
|
#include "menu.hh"
|
||||||
|
#include "help_box.hh"
|
||||||
|
#include "virtual_keyboard.hh"
|
||||||
|
|
||||||
|
#include <sysdeps.h>
|
||||||
|
#include <C64.h>
|
||||||
|
|
||||||
|
class NetworkRegionView;
|
||||||
|
|
||||||
|
class NetworkRegionMenu : public Menu
|
||||||
|
{
|
||||||
|
friend class NetworkRegionView;
|
||||||
|
|
||||||
|
public:
|
||||||
|
NetworkRegionMenu(Font *font) : Menu(font)
|
||||||
|
{
|
||||||
|
memset(this->messages, 0, sizeof(this->messages));
|
||||||
|
for (int i = REGION_UNKNOWN; i < REGION_ANTARTICA; i++)
|
||||||
|
this->messages[i] = region_to_str(i);
|
||||||
|
|
||||||
|
this->setText(this->messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
~NetworkRegionMenu()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void selectCallback(int which)
|
||||||
|
{
|
||||||
|
Gui::gui->np->NetworkRegion = which;
|
||||||
|
Gui::gui->popView();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void escapeCallback(int which)
|
||||||
|
{
|
||||||
|
Gui::gui->popView();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void hoverCallback(int which)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateMessages()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *messages[REGION_ANTARTICA + 1];
|
||||||
|
|
||||||
|
HelpBox *help;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class NetworkRegionView : public GuiView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NetworkRegionView() : GuiView()
|
||||||
|
{
|
||||||
|
this->menu = new NetworkRegionMenu(Gui::gui->default_font);
|
||||||
|
}
|
||||||
|
|
||||||
|
~NetworkRegionView()
|
||||||
|
{
|
||||||
|
delete this->menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void runLogic()
|
||||||
|
{
|
||||||
|
this->menu->runLogic();
|
||||||
|
}
|
||||||
|
|
||||||
|
void pushEvent(SDL_Event *ev)
|
||||||
|
{
|
||||||
|
this->menu->pushEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void viewPushCallback()
|
||||||
|
{
|
||||||
|
this->menu->updateMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw(SDL_Surface *where)
|
||||||
|
{
|
||||||
|
SDL_Rect dst;
|
||||||
|
|
||||||
|
/* Blit the backgrounds */
|
||||||
|
dst = (SDL_Rect){20,45,300,400};
|
||||||
|
SDL_BlitSurface(Gui::gui->main_menu_bg, NULL, where, &dst);
|
||||||
|
|
||||||
|
dst = (SDL_Rect){350,13,0,0};
|
||||||
|
SDL_BlitSurface(Gui::gui->infobox, NULL, where, &dst);
|
||||||
|
|
||||||
|
this->menu->draw(where, 50, 70, 300, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
NetworkRegionMenu *menu;
|
||||||
|
};
|
@ -48,20 +48,7 @@ public:
|
|||||||
|
|
||||||
const char *getRegion()
|
const char *getRegion()
|
||||||
{
|
{
|
||||||
switch (this->region)
|
return region_to_str(this->region);
|
||||||
{
|
|
||||||
case 1: return "Europe";
|
|
||||||
case 2: return "Africa";
|
|
||||||
case 3: return "North America";
|
|
||||||
case 4: return "South America";
|
|
||||||
case 5: return "Asia";
|
|
||||||
case 6: return "Australia";
|
|
||||||
case 7: return "Antartica"; // Likely, yes
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Unknown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface *scr;
|
SDL_Surface *scr;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <sysdeps.h>
|
#include <sysdeps.h>
|
||||||
#include <C64.h>
|
#include <C64.h>
|
||||||
|
#include <Network.h>
|
||||||
|
|
||||||
#include "gui/font.hh"
|
#include "gui/font.hh"
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
@ -342,3 +343,23 @@ const char *ip_to_str(uint8_t *ip_in)
|
|||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *region_to_str(int region)
|
||||||
|
{
|
||||||
|
switch (region)
|
||||||
|
{
|
||||||
|
case REGION_EUROPE: return "Europe";
|
||||||
|
case REGION_AFRICA: return "Africa";
|
||||||
|
case REGION_NORTH_AMERICA: return "North America";
|
||||||
|
case REGION_SOUTH_AMERICA: return "South America";
|
||||||
|
case REGION_EAST_ASIA: return "East asia";
|
||||||
|
case REGION_SOUTH_ASIA: return "South asia";
|
||||||
|
case REGION_MIDDLE_EAST: return "Middle east";
|
||||||
|
case REGION_OCEANIA: return "Oceania";
|
||||||
|
case REGION_ANTARTICA: return "Antartica"; // Likely, yes
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
@ -86,4 +86,6 @@ void highlight_background(SDL_Surface *where, Font *font,
|
|||||||
|
|
||||||
const char *ip_to_str(uint8_t *ip_in);
|
const char *ip_to_str(uint8_t *ip_in);
|
||||||
|
|
||||||
|
const char *region_to_str(int region);
|
||||||
|
|
||||||
#endif /* __UTILS_H__ */
|
#endif /* __UTILS_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user