#define SETUP_TOKEN_VOLUME_SIMPLE 38
#define SETUP_TOKEN_VOLUME_LOOPS 39
#define SETUP_TOKEN_VOLUME_MUSIC 40
-#define SETUP_TOKEN_TOUCH_CONTROL_TYPE 41
-#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE 42
-#define SETUP_TOKEN_TOUCH_DROP_DISTANCE 43
-#define SETUP_TOKEN_TOUCH_TRANSPARENCY 44
-#define SETUP_TOKEN_TOUCH_DRAW_OUTLINED 45
-#define SETUP_TOKEN_TOUCH_DRAW_PRESSED 46
-#define SETUP_TOKEN_TOUCH_GRID_XSIZE_0 47
-#define SETUP_TOKEN_TOUCH_GRID_YSIZE_0 48
-#define SETUP_TOKEN_TOUCH_GRID_XSIZE_1 49
-#define SETUP_TOKEN_TOUCH_GRID_YSIZE_1 50
-#define SETUP_TOKEN_NETWORK_MODE 51
-
-#define NUM_GLOBAL_SETUP_TOKENS 52
+#define SETUP_TOKEN_NETWORK_MODE 41
+#define SETUP_TOKEN_NETWORK_PLAYER_NR 42
+#define SETUP_TOKEN_TOUCH_CONTROL_TYPE 43
+#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE 44
+#define SETUP_TOKEN_TOUCH_DROP_DISTANCE 45
+#define SETUP_TOKEN_TOUCH_TRANSPARENCY 46
+#define SETUP_TOKEN_TOUCH_DRAW_OUTLINED 47
+#define SETUP_TOKEN_TOUCH_DRAW_PRESSED 48
+#define SETUP_TOKEN_TOUCH_GRID_XSIZE_0 49
+#define SETUP_TOKEN_TOUCH_GRID_YSIZE_0 50
+#define SETUP_TOKEN_TOUCH_GRID_XSIZE_1 51
+#define SETUP_TOKEN_TOUCH_GRID_YSIZE_1 52
+
+#define NUM_GLOBAL_SETUP_TOKENS 53
/* auto setup */
#define SETUP_TOKEN_AUTO_EDITOR_ZOOM_TILESIZE 0
{ TYPE_INTEGER,&si.volume_simple, "volume_simple" },
{ TYPE_INTEGER,&si.volume_loops, "volume_loops" },
{ TYPE_INTEGER,&si.volume_music, "volume_music" },
+ { TYPE_SWITCH, &si.network_mode, "network_mode" },
+ { TYPE_PLAYER, &si.network_player_nr, "network_player" },
{ TYPE_STRING, &si.touch.control_type, "touch.control_type" },
{ TYPE_INTEGER,&si.touch.move_distance, "touch.move_distance" },
{ TYPE_INTEGER,&si.touch.drop_distance, "touch.drop_distance" },
{ TYPE_INTEGER,&si.touch.grid_ysize[0], "touch.virtual_buttons.0.ysize" },
{ TYPE_INTEGER,&si.touch.grid_xsize[1], "touch.virtual_buttons.1.xsize" },
{ TYPE_INTEGER,&si.touch.grid_ysize[1], "touch.virtual_buttons.1.ysize" },
- { TYPE_SWITCH, &si.network_mode, "network_mode" },
};
static struct TokenInfo auto_setup_tokens[] =
si->volume_loops = 100; /* percent */
si->volume_music = 100; /* percent */
+ si->network_mode = FALSE;
+ si->network_player_nr = 0; /* first player */
+
si->touch.control_type = getStringCopy(TOUCH_CONTROL_DEFAULT);
si->touch.move_distance = TOUCH_MOVE_DISTANCE_DEFAULT; /* percent */
si->touch.drop_distance = TOUCH_DROP_DISTANCE_DEFAULT; /* percent */
si->touch.grid_initialized = video.initialized;
- si->network_mode = FALSE;
-
si->editor.el_boulderdash = TRUE;
si->editor.el_emerald_mine = TRUE;
si->editor.el_emerald_mine_club = TRUE;
if (i == SETUP_TOKEN_PLAYER_NAME + 1 ||
i == SETUP_TOKEN_GRAPHICS_SET ||
i == SETUP_TOKEN_VOLUME_SIMPLE ||
+ i == SETUP_TOKEN_NETWORK_MODE ||
i == SETUP_TOKEN_TOUCH_CONTROL_TYPE ||
i == SETUP_TOKEN_TOUCH_GRID_XSIZE_0 ||
i == SETUP_TOKEN_TOUCH_GRID_XSIZE_1)
void InitNetworkServer()
{
-#if defined(NETWORK_AVALIABLE)
- int nr_wanted;
-#endif
-
if (setup.network_mode)
options.network = TRUE;
return;
#if defined(NETWORK_AVALIABLE)
- nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
-
if (!ConnectToServer(options.server_host, options.server_port))
Error(ERR_EXIT, "cannot connect to network game server");
SendToServer_PlayerName(setup.player_name);
SendToServer_ProtocolVersion();
-
- if (nr_wanted)
- SendToServer_NrWanted(nr_wanted);
+ SendToServer_NrWanted(setup.network_player_nr + 1);
#endif
}
return result;
}
+int get_player_nr_from_string(char *s)
+{
+ static char *player_text[] =
+ {
+ "player_1",
+ "player_2",
+ "player_3",
+ "player_4",
+
+ NULL
+ };
+
+ char *s_lower = getStringToLower(s);
+ int result = 0;
+ int i;
+
+ for (i = 0; player_text[i] != NULL; i++)
+ if (strEqual(s_lower, player_text[i]))
+ result = i;
+
+ free(s_lower);
+
+ return result;
+}
+
/* ------------------------------------------------------------------------- */
/* functions for generic lists */
int get_integer_from_string(char *);
boolean get_boolean_from_string(char *);
int get_switch3_from_string(char *);
+int get_player_nr_from_string(char *);
ListNode *newListNode(void);
void addNodeToList(ListNode **, char *, void *);
*(char **)setup_value = getStringCopy(token_value);
break;
+ case TYPE_PLAYER:
+ *(int *)setup_value = get_player_nr_from_string(token_value);
+ break;
+
default:
break;
}
strcpy(value_string, *(char **)value);
break;
+ case TYPE_PLAYER:
+ sprintf(value_string, "player_%d", *(int *)value + 1);
+ break;
+
default:
value_string[0] = '\0';
break;
#define TYPE_KEY_X11 (1 << 7)
#define TYPE_INTEGER (1 << 8)
#define TYPE_STRING (1 << 9)
-#define TYPE_ELEMENT (1 << 10)
-#define TYPE_GRAPHIC (1 << 11)
+#define TYPE_PLAYER (1 << 10)
+#define TYPE_ELEMENT (1 << 11)
+#define TYPE_GRAPHIC (1 << 12)
/* additional values for setup screen */
-#define TYPE_ENTER_SCREEN (1 << 12)
-#define TYPE_LEAVE_SCREEN (1 << 13)
-#define TYPE_ENTER_MENU (1 << 14)
-#define TYPE_LEAVE_MENU (1 << 15)
-#define TYPE_ENTER_LIST (1 << 16)
-#define TYPE_LEAVE_LIST (1 << 17)
-#define TYPE_EMPTY (1 << 18)
-#define TYPE_SKIPPABLE (1 << 19)
-#define TYPE_KEYTEXT (1 << 20)
-
-#define TYPE_GHOSTED (1 << 21)
-#define TYPE_QUERY (1 << 22)
+#define TYPE_ENTER_SCREEN (1 << 13)
+#define TYPE_LEAVE_SCREEN (1 << 14)
+#define TYPE_ENTER_MENU (1 << 15)
+#define TYPE_LEAVE_MENU (1 << 16)
+#define TYPE_ENTER_LIST (1 << 17)
+#define TYPE_LEAVE_LIST (1 << 18)
+#define TYPE_EMPTY (1 << 19)
+#define TYPE_SKIPPABLE (1 << 20)
+#define TYPE_KEYTEXT (1 << 21)
+
+#define TYPE_GHOSTED (1 << 22)
+#define TYPE_QUERY (1 << 23)
/* additional values for internal purposes */
-#define TYPE_BITFIELD (1 << 23)
-#define TYPE_CONTENT (1 << 24)
-#define TYPE_ELEMENT_LIST (1 << 25)
-#define TYPE_CONTENT_LIST (1 << 26)
+#define TYPE_BITFIELD (1 << 24)
+#define TYPE_CONTENT (1 << 25)
+#define TYPE_ELEMENT_LIST (1 << 26)
+#define TYPE_CONTENT_LIST (1 << 27)
/* derived values for setup file handling */
#define TYPE_BOOLEAN_STYLE (TYPE_BOOLEAN | \
TYPE_KEY_X11 | \
TYPE_INTEGER | \
TYPE_STRING | \
+ TYPE_PLAYER | \
TYPE_ELEMENT | \
TYPE_GRAPHIC)
int volume_music;
boolean network_mode;
+ int network_player_nr;
struct SetupAutoSetupInfo auto_setup;
struct SetupEditorInfo editor;
TYPE_YES_NO |
TYPE_YES_NO_AUTO |
TYPE_STRING |
+ TYPE_PLAYER |
TYPE_ECS_AGA |
TYPE_KEYTEXT |
TYPE_ENTER_LIST))
if (menu_info[choice].type & menu_navigation_type ||
menu_info[choice].type & TYPE_BOOLEAN_STYLE ||
- menu_info[choice].type & TYPE_YES_NO_AUTO)
+ menu_info[choice].type & TYPE_YES_NO_AUTO ||
+ menu_info[choice].type & TYPE_PLAYER)
button = MB_MENU_CHOICE;
}
else if (dy)
{
{ TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
{ TYPE_SWITCH, &setup.network_mode, "Network Multi-Player Mode:" },
+ { TYPE_PLAYER, &setup.network_player_nr,"Preferred Network Player:" },
{ TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
{ TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
{ TYPE_SWITCH, &setup.handicap, "Handicap:" },
else if (type & TYPE_YES_NO_AUTO)
return (*(int *)value == AUTO ? FONT_OPTION_ON :
*(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
+ else if (type & TYPE_PLAYER)
+ return FONT_VALUE_1;
else
return FONT_VALUE_1;
}
{
xpos = menu_screen_value_xpos - 1;
}
+ else if (type & TYPE_PLAYER)
+ {
+ int displayed_player_nr = *(int *)value + 1;
+
+ value_string = getSetupValue(TYPE_INTEGER, (void *)&displayed_player_nr);
+ }
startx = mSX + xpos * 32;
starty = mSY + ypos * 32;
DrawText(startx, starty, value_string, font_nr);
+ if (type & TYPE_PLAYER)
+ {
+ int player_nr = *(int *)value;
+ int xoff = getFontWidth(font_nr);
+
+ DrawFixedGraphicThruMaskExt(drawto, startx + xoff, starty,
+ PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
+ }
+
if (font_draw_xoffset_modified)
getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
}
if (key != KSYM_UNDEFINED)
*(Key *)si->value = key;
}
+ else if (si->type & TYPE_PLAYER)
+ {
+ int player_nr = *(int *)si->value;
+
+ if (dx)
+ player_nr += dx;
+ else
+ player_nr = Request("Choose player", REQ_PLAYER) - 1;
+
+ *(int *)si->value = MIN(MAX(0, player_nr), MAX_PLAYERS - 1);
+ }
drawSetupValue(screen_pos, setup_info_pos_raw);