More changes for online key config; config is shown but not editable.

The default key configuration has been slightly modified for easier
display, but the VControl template is still compatible.  The default
keys.cfg prior to this will not render properly but still works.


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2425 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2006-09-02 09:28:02 +00:00
parent e0366a964f
commit 127bf24b30
9 changed files with 339 additions and 98 deletions
+2
View File
@@ -1,4 +1,6 @@
Changes towards version 0.6: Changes towards version 0.6:
- Default key configuration changed slightly; online display of current
key bindings - Michael
- Input templates can now be renamed, both online and off - Michael - Input templates can now be renamed, both online and off - Michael
- Fixed an integer-size error that was causing crashes on AMD64, from - Fixed an integer-size error that was causing crashes on AMD64, from
Solomon Peachy (#895) - Michael Solomon Peachy (#895) - Michael
+23
View File
@@ -378,21 +378,33 @@ Placeholder
Placeholder Placeholder
#(CAT_20_OPT_0_DESC) #(CAT_20_OPT_0_DESC)
Select the control template to edit. Select the control template to edit.
#(CAT_20_OPT_1_DESC) #(CAT_20_OPT_1_DESC)
Select the control template to edit. Select the control template to edit.
#(CAT_20_OPT_2_DESC) #(CAT_20_OPT_2_DESC)
Select the control template to edit. Select the control template to edit.
#(CAT_20_OPT_3_DESC) #(CAT_20_OPT_3_DESC)
Select the control template to edit. Select the control template to edit.
#(CAT_20_OPT_4_DESC) #(CAT_20_OPT_4_DESC)
Select the control template to edit. Select the control template to edit.
#(CAT_20_OPT_5_DESC) #(CAT_20_OPT_5_DESC)
Select the control template to edit. Select the control template to edit.
#(SLIDERS) #(SLIDERS)
@@ -458,6 +470,8 @@ hardware-dependent options.
Edit key control sets. Edit key control sets.
#(BUTTON_9_DESC) #(BUTTON_9_DESC)
Return to control set selection screen. Return to control set selection screen.
#(LABELS) #(LABELS)
@@ -483,3 +497,12 @@ Name
#(TEXT_ENTRIES_INITIAL) #(TEXT_ENTRIES_INITIAL)
Placeholder Placeholder
#(CONTROL_ENTRIES)
Up
Down
Left
Right
Weapon
Special
Escape
+71 -80
View File
@@ -30,11 +30,6 @@ Menu-Select: key Return
Menu-Select: key RightControl Menu-Select: key RightControl
Menu-Cancel: key Space Menu-Cancel: key Space
Menu-Cancel: key RightShift Menu-Cancel: key RightShift
Menu-Delete: key Delete
Menu-Backspace: key Backspace
Menu-Edit-Cancel: key Escape
Menu-Search: key /
Menu-Next: key Tab
# ... and the number pad. Note that zoom controls on the starmap are # ... and the number pad. Note that zoom controls on the starmap are
# different from the paging controls in Super Melee. # different from the paging controls in Super Melee.
@@ -52,18 +47,28 @@ Menu-Select: key Keypad-Enter
Menu-Cancel: key Keypad-0 Menu-Cancel: key Keypad-0
Menu-Delete: key Keypad-. Menu-Delete: key Keypad-.
# Player 1's flight controls. This is the bottom player in Super # System utility keys.
# Melee and the player in the full game. Again, the player has the Menu-Delete: key Delete
# option of using either the number pad or the arrow keys. Menu-Backspace: key Backspace
Menu-Edit-Cancel: key Escape
Menu-Search: key /
Menu-Next: key Tab
Pause: key Pause
Pause: key F1
Exit: key F10
# Arrow-key controls. This is the default for the bottom player in
# Super Melee and the player in the full game. Again, the player has
# the option of using either the number pad or the arrow keys.
Keyboard-1-Up: key Up Keyboard-1-Up: key Up
Keyboard-1-Down: key Down Keyboard-1-Down: key Down
Keyboard-1-Left: key Left Keyboard-1-Left: key Left
Keyboard-1-Right: key Right Keyboard-1-Right: key Right
Keyboard-1-Weapon: key Return
Keyboard-1-Weapon: key RightControl Keyboard-1-Weapon: key RightControl
Keyboard-1-Special: key RightShift Keyboard-1-Special: key RightShift
Keyboard-1-Escape: key Escape
Keyboard-1-Up: key Keypad-8 Keyboard-1-Up: key Keypad-8
Keyboard-1-Down: key Keypad-2 Keyboard-1-Down: key Keypad-2
@@ -72,23 +77,43 @@ Keyboard-1-Right: key Keypad-6
Keyboard-1-Weapon: key Keypad-Enter Keyboard-1-Weapon: key Keypad-Enter
Keyboard-1-Special: key Keypad-0 Keyboard-1-Special: key Keypad-0
Keyboard-1-Weapon: key ] Keyboard-1-Escape: key Escape
Keyboard-1-Special: key [
# Player 2's flight controls. We add the key 'd' to let him # WASD for Player 2's default flight controls. We add the key 'd' to
# move down in the super-melee ship selection. # let him move down in the super-melee ship selection.
Keyboard-2-Up: key e
Keyboard-2-Down: key d Keyboard-2-Up: key w
Keyboard-2-Left: key s Keyboard-2-Down: key s
Keyboard-2-Right: key f Keyboard-2-Left: key a
Keyboard-2-Weapon: key q Keyboard-2-Right: key d
Keyboard-2-Special: key a Keyboard-2-Weapon: key v
Keyboard-2-Special: key b
Keyboard-2-Escape: key Escape Keyboard-2-Escape: key Escape
# System utility keys. # Control Scheme 3: Variant Arrow keys with brackets for firing.
Pause: key Pause
Pause: key F1 Keyboard-3-Up: key Keypad-8
Exit: key F10 Keyboard-3-Down: key Keypad-2
Keyboard-3-Left: key Keypad-4
Keyboard-3-Right: key Keypad-6
Keyboard-3-Up: key Up
Keyboard-3-Down: key Down
Keyboard-3-Left: key Left
Keyboard-3-Right: key Right
Keyboard-3-Weapon: key ]
Keyboard-3-Special: key [
Keyboard-3-Escape: key Escape
# Control Scheme 4: Shifted WASD keys.
Joystick-1-Up: key e
Joystick-1-Down: key d
Joystick-1-Left: key s
Joystick-1-Right: key f
Joystick-1-Weapon: key q
Joystick-1-Special: key a
Joystick-1-Escape: key Escape
# This is a sample joystick configuration. This is intended to work # This is a sample joystick configuration. This is intended to work
# primarily under WinXP with a USB analog/digital gamepad. The # primarily under WinXP with a USB analog/digital gamepad. The
@@ -100,19 +125,19 @@ Exit: key F10
joystick 0 threshold 10000 # How far to move before it counts; 0-30000 joystick 0 threshold 10000 # How far to move before it counts; 0-30000
Joystick-1-Up: joystick 0 axis 1 negative Joystick-2-Up: joystick 0 axis 1 negative
Joystick-1-Down: joystick 0 axis 1 positive Joystick-2-Down: joystick 0 axis 1 positive
Joystick-1-Left: joystick 0 axis 0 negative Joystick-2-Left: joystick 0 axis 0 negative
Joystick-1-Right: joystick 0 axis 0 positive Joystick-2-Right: joystick 0 axis 0 positive
Joystick-1-Up: joystick 0 hat 0 up Joystick-2-Up: joystick 0 hat 0 up
Joystick-1-Down: joystick 0 hat 0 down Joystick-2-Down: joystick 0 hat 0 down
Joystick-1-Left: joystick 0 hat 0 left Joystick-2-Left: joystick 0 hat 0 left
Joystick-1-Right: joystick 0 hat 0 right Joystick-2-Right: joystick 0 hat 0 right
Joystick-1-Weapon: joystick 0 button 1 Joystick-2-Weapon: joystick 0 button 1
Joystick-1-Special: joystick 0 button 0 Joystick-2-Special: joystick 0 button 0
Joystick-1-Escape: joystick 0 button 6 Joystick-2-Escape: joystick 0 button 6
Menu-Up: joystick 0 axis 1 negative Menu-Up: joystick 0 axis 1 negative
Menu-Down: joystick 0 axis 1 positive Menu-Down: joystick 0 axis 1 positive
@@ -133,19 +158,19 @@ Menu-Zoom-Out: joystick 0 button 7
joystick 1 threshold 10000 # How far to move before it counts; 0-30000 joystick 1 threshold 10000 # How far to move before it counts; 0-30000
Joystick-2-Up: joystick 1 axis 1 negative Joystick-3-Up: joystick 1 axis 1 negative
Joystick-2-Down: joystick 1 axis 1 positive Joystick-3-Down: joystick 1 axis 1 positive
Joystick-2-Left: joystick 1 axis 0 negative Joystick-3-Left: joystick 1 axis 0 negative
Joystick-2-Right: joystick 1 axis 0 positive Joystick-3-Right: joystick 1 axis 0 positive
Joystick-2-Up: joystick 1 hat 0 up Joystick-3-Up: joystick 1 hat 0 up
Joystick-2-Down: joystick 1 hat 0 down Joystick-3-Down: joystick 1 hat 0 down
Joystick-2-Left: joystick 1 hat 0 left Joystick-3-Left: joystick 1 hat 0 left
Joystick-2-Right: joystick 1 hat 0 right Joystick-3-Right: joystick 1 hat 0 right
Joystick-2-Weapon: joystick 1 button 1 Joystick-3-Weapon: joystick 1 button 1
Joystick-2-Special: joystick 1 button 0 Joystick-3-Special: joystick 1 button 0
Joystick-2-Escape: joystick 1 button 6 Joystick-3-Escape: joystick 1 button 6
Menu-Up: joystick 1 axis 1 negative Menu-Up: joystick 1 axis 1 negative
Menu-Down: joystick 1 axis 1 positive Menu-Down: joystick 1 axis 1 positive
@@ -163,37 +188,3 @@ Menu-Page-Up: joystick 1 button 4
Menu-Page-Down: joystick 1 button 5 Menu-Page-Down: joystick 1 button 5
Menu-Zoom-In: joystick 1 button 6 Menu-Zoom-In: joystick 1 button 6
Menu-Zoom-Out: joystick 1 button 7 Menu-Zoom-Out: joystick 1 button 7
joystick 2 threshold 10000 # How far to move before it counts; 0-30000
Joystick-3-Up: joystick 2 axis 1 negative
Joystick-3-Down: joystick 2 axis 1 positive
Joystick-3-Left: joystick 2 axis 0 negative
Joystick-3-Right: joystick 2 axis 0 positive
Joystick-3-Up: joystick 2 hat 0 up
Joystick-3-Down: joystick 2 hat 0 down
Joystick-3-Left: joystick 2 hat 0 left
Joystick-3-Right: joystick 2 hat 0 right
Joystick-3-Weapon: joystick 2 button 1
Joystick-3-Special: joystick 2 button 0
Joystick-3-Escape: joystick 2 button 6
Menu-Up: joystick 2 axis 1 negative
Menu-Down: joystick 2 axis 1 positive
Menu-Left: joystick 2 axis 0 negative
Menu-Right: joystick 2 axis 0 positive
Menu-Up: joystick 2 hat 0 up
Menu-Down: joystick 2 hat 0 down
Menu-Left: joystick 2 hat 0 left
Menu-Right: joystick 2 hat 0 right
Menu-Cancel: joystick 2 button 0
Menu-Select: joystick 2 button 1
Menu-Page-Up: joystick 2 button 4
Menu-Page-Down: joystick 2 button 5
Menu-Zoom-In: joystick 2 button 6
Menu-Zoom-Out: joystick 2 button 7
+92
View File
@@ -475,6 +475,66 @@ Widget_DrawTextEntry (WIDGET *_self, int x, int y)
SetContextForeGroundColor (oldtext); SetContextForeGroundColor (oldtext);
} }
void
Widget_DrawControlEntry (WIDGET *_self, int x, int y)
{
WIDGET_CONTROLENTRY *self = (WIDGET_CONTROLENTRY *)_self;
COLOR oldtext;
COLOR inactive, default_color, selected;
FONT oldfont = SetContextFont (StarConFont);
FRAME oldFontEffect = SetContextFontEffect (NULL);
TEXT t;
int i, home_x, home_y;
default_color = WIDGET_INACTIVE_SELECTED_COLOR;
selected = WIDGET_ACTIVE_COLOR;
inactive = WIDGET_INACTIVE_COLOR;
t.baseline.x = x;
t.baseline.y = y;
t.align = ALIGN_LEFT;
t.valign = VALIGN_BOTTOM;
t.CharCount = ~0;
t.pStr = self->category;
if (widget_focus == _self)
{
oldtext = SetContextForeGroundColor (selected);
}
else
{
oldtext = SetContextForeGroundColor (default_color);
}
font_DrawText (&t);
// 3 * SCREEN_WIDTH / ((self->maxcolumns + 1) * 2)) as per CHOICE, but only two options.
home_x = t.baseline.x + (SCREEN_WIDTH / 2);
home_y = t.baseline.y;
t.align = ALIGN_CENTER;
for (i = 0; i < 2; i++)
{
t.baseline.x = home_x + ((i % 3) * (SCREEN_WIDTH / 3)); // self->maxcolumns + 1 as per CHOICE.
t.baseline.y = home_y + (8 * (i / 3));
t.pStr = self->controlname[i];
if (!t.pStr[0])
{
t.pStr = "---";
}
if ((widget_focus == _self) &&
(self->highlighted == i))
{
SetContextForeGroundColor (selected);
}
else
{
SetContextForeGroundColor (default_color);
}
font_DrawText (&t);
}
SetContextFontEffect (oldFontEffect);
SetContextFont (oldfont);
SetContextForeGroundColor (oldtext);
}
int int
Widget_HeightChoice (WIDGET *_self) Widget_HeightChoice (WIDGET *_self)
{ {
@@ -527,6 +587,21 @@ Widget_ReceiveFocusChoice (WIDGET *_self, int event)
return TRUE; return TRUE;
} }
int
Widget_ReceiveFocusControlEntry (WIDGET *_self, int event)
{
WIDGET_CONTROLENTRY *self = (WIDGET_CONTROLENTRY *)_self;
int oldval = 0;
if (widget_focus->tag == WIDGET_TYPE_CONTROLENTRY)
{
oldval = ((WIDGET_CONTROLENTRY *)widget_focus)->highlighted;
}
widget_focus = _self;
self->highlighted = oldval;
(void)event;
return TRUE;
}
int int
Widget_ReceiveFocusMenuScreen (WIDGET *_self, int event) Widget_ReceiveFocusMenuScreen (WIDGET *_self, int event)
{ {
@@ -688,6 +763,23 @@ Widget_HandleEventTextEntry (WIDGET *_self, int event)
return FALSE; return FALSE;
} }
int
Widget_HandleEventControlEntry (WIDGET *_self, int event)
{
WIDGET_CONTROLENTRY *self = (WIDGET_CONTROLENTRY *)_self;
if (event == WIDGET_EVENT_SELECT)
{
/* TODO: Something. */
(void)self;
}
if ((event == WIDGET_EVENT_RIGHT) ||
(event == WIDGET_EVENT_LEFT))
{
self->highlighted = 1-self->highlighted;
}
return FALSE;
}
int int
Widget_Event (int event) Widget_Event (int event)
{ {
+35
View File
@@ -31,9 +31,22 @@ enum {
NUM_WIDGET_EVENTS NUM_WIDGET_EVENTS
}; };
typedef enum {
WIDGET_TYPE_MENU_SCREEN,
WIDGET_TYPE_CHOICE,
WIDGET_TYPE_BUTTON,
WIDGET_TYPE_LABEL,
WIDGET_TYPE_SLIDER,
WIDGET_TYPE_TEXTENTRY,
WIDGET_TYPE_CONTROLENTRY,
NUM_WIDGET_TYPES
} WIDGET_TYPE;
#define WIDGET_TEXTENTRY_WIDTH 30 #define WIDGET_TEXTENTRY_WIDTH 30
#define WIDGET_CONTROLENTRY_WIDTH 16
typedef struct _widget { typedef struct _widget {
WIDGET_TYPE tag;
struct _widget *parent; struct _widget *parent;
int (*handleEvent)(struct _widget *self, int event); int (*handleEvent)(struct _widget *self, int event);
int (*receiveFocus)(struct _widget *self, int event); int (*receiveFocus)(struct _widget *self, int event);
@@ -43,6 +56,7 @@ typedef struct _widget {
} WIDGET; } WIDGET;
typedef struct _widget_menu_screen { typedef struct _widget_menu_screen {
WIDGET_TYPE tag;
struct _widget *parent; struct _widget *parent;
int (*handleEvent)(struct _widget *self, int event); int (*handleEvent)(struct _widget *self, int event);
int (*receiveFocus)(struct _widget *self, int event); int (*receiveFocus)(struct _widget *self, int event);
@@ -63,6 +77,7 @@ typedef struct {
} CHOICE_OPTION; } CHOICE_OPTION;
typedef struct _widget_choice { typedef struct _widget_choice {
WIDGET_TYPE tag;
struct _widget *parent; struct _widget *parent;
int (*handleEvent)(struct _widget *self, int event); int (*handleEvent)(struct _widget *self, int event);
int (*receiveFocus)(struct _widget *self, int event); int (*receiveFocus)(struct _widget *self, int event);
@@ -78,6 +93,7 @@ typedef struct _widget_choice {
} WIDGET_CHOICE; } WIDGET_CHOICE;
typedef struct _widget_button { typedef struct _widget_button {
WIDGET_TYPE tag;
struct _widget *parent; struct _widget *parent;
int (*handleEvent)(struct _widget *self, int event); int (*handleEvent)(struct _widget *self, int event);
int (*receiveFocus)(struct _widget *self, int event); int (*receiveFocus)(struct _widget *self, int event);
@@ -89,6 +105,7 @@ typedef struct _widget_button {
} WIDGET_BUTTON; } WIDGET_BUTTON;
typedef struct _widget_label { typedef struct _widget_label {
WIDGET_TYPE tag;
struct _widget *parent; struct _widget *parent;
int (*handleEvent)(struct _widget *self, int event); int (*handleEvent)(struct _widget *self, int event);
int (*receiveFocus)(struct _widget *self, int event); int (*receiveFocus)(struct _widget *self, int event);
@@ -100,6 +117,7 @@ typedef struct _widget_label {
} WIDGET_LABEL; } WIDGET_LABEL;
typedef struct _widget_slider { typedef struct _widget_slider {
WIDGET_TYPE tag;
struct _widget *parent; struct _widget *parent;
int (*handleEvent)(struct _widget *self, int event); int (*handleEvent)(struct _widget *self, int event);
int (*receiveFocus)(struct _widget *self, int event); int (*receiveFocus)(struct _widget *self, int event);
@@ -121,6 +139,7 @@ typedef enum {
} WIDGET_TEXTENTRY_STATE; } WIDGET_TEXTENTRY_STATE;
typedef struct _widget_textentry { typedef struct _widget_textentry {
WIDGET_TYPE tag;
struct _widget *parent; struct _widget *parent;
int (*handleEvent)(struct _widget *self, int event); int (*handleEvent)(struct _widget *self, int event);
int (*receiveFocus)(struct _widget *self, int event); int (*receiveFocus)(struct _widget *self, int event);
@@ -139,6 +158,19 @@ typedef struct _widget_textentry {
int cursor_pos; int cursor_pos;
} WIDGET_TEXTENTRY; } WIDGET_TEXTENTRY;
typedef struct _widget_controlentry {
WIDGET_TYPE tag;
struct _widget *parent;
int (*handleEvent)(struct _widget *self, int event);
int (*receiveFocus)(struct _widget *self, int event);
void (*draw)(struct _widget *self, int x, int y);
int (*height)(struct _widget *self);
int (*width)(struct _widget *self);
const char *category;
int highlighted;
char controlname[2][WIDGET_CONTROLENTRY_WIDTH];
} WIDGET_CONTROLENTRY;
void DrawShadowedBox (PRECT r, COLOR bg, COLOR dark, COLOR medium); void DrawShadowedBox (PRECT r, COLOR bg, COLOR dark, COLOR medium);
int Widget_Event (int event); int Widget_Event (int event);
@@ -149,12 +181,14 @@ int Widget_ReceiveFocusMenuScreen (WIDGET *_self, int event);
int Widget_ReceiveFocusChoice (WIDGET *_self, int event); int Widget_ReceiveFocusChoice (WIDGET *_self, int event);
int Widget_ReceiveFocusSimple (WIDGET *_self, int event); int Widget_ReceiveFocusSimple (WIDGET *_self, int event);
int Widget_ReceiveFocusSlider (WIDGET *_self, int event); int Widget_ReceiveFocusSlider (WIDGET *_self, int event);
int Widget_ReceiveFocusControlEntry (WIDGET *_self, int event);
int Widget_ReceiveFocusRefuseFocus (WIDGET *_self, int event); int Widget_ReceiveFocusRefuseFocus (WIDGET *_self, int event);
int Widget_HandleEventMenuScreen (WIDGET *_self, int event); int Widget_HandleEventMenuScreen (WIDGET *_self, int event);
int Widget_HandleEventChoice (WIDGET *_self, int event); int Widget_HandleEventChoice (WIDGET *_self, int event);
int Widget_HandleEventSlider (WIDGET *_self, int event); int Widget_HandleEventSlider (WIDGET *_self, int event);
int Widget_HandleEventTextEntry (WIDGET *_self, int event); int Widget_HandleEventTextEntry (WIDGET *_self, int event);
int Widget_HandleEventControlEntry (WIDGET *_self, int event);
int Widget_HandleEventIgnoreAll (WIDGET *_self, int event); int Widget_HandleEventIgnoreAll (WIDGET *_self, int event);
int Widget_HeightChoice (WIDGET *_self); int Widget_HeightChoice (WIDGET *_self);
@@ -170,6 +204,7 @@ void Widget_DrawButton (WIDGET *_self, int x, int y);
void Widget_DrawLabel (WIDGET *_self, int x, int y); void Widget_DrawLabel (WIDGET *_self, int x, int y);
void Widget_DrawSlider (WIDGET *_self, int x, int y); void Widget_DrawSlider (WIDGET *_self, int x, int y);
void Widget_DrawTextEntry (WIDGET *_self, int x, int y); void Widget_DrawTextEntry (WIDGET *_self, int x, int y);
void Widget_DrawControlEntry (WIDGET *_self, int x, int y);
void Widget_Slider_DrawValue (WIDGET_SLIDER *self, int x, int y); void Widget_Slider_DrawValue (WIDGET_SLIDER *self, int x, int y);
+3
View File
@@ -46,6 +46,9 @@ void DisableCharacterMode (void);
wchar_t GetNextCharacter (void); wchar_t GetNextCharacter (void);
wchar_t GetLastCharacter (void); wchar_t GetLastCharacter (void);
/* Interrogating the current key configuration */
void InterrogateInputState (int template, int control, int index, char *buffer, int maxlen);
#endif /* _INPLIB_H */ #endif /* _INPLIB_H */
+36
View File
@@ -23,6 +23,7 @@
#include "libs/graphics/sdl/sdl_common.h" #include "libs/graphics/sdl/sdl_common.h"
#include "libs/input/input_common.h" #include "libs/input/input_common.h"
#include "libs/input/sdl/vcontrol.h" #include "libs/input/sdl/vcontrol.h"
#include "libs/input/sdl/keynames.h"
#include "controls.h" #include "controls.h"
#include "libs/file.h" #include "libs/file.h"
#include "libs/log.h" #include "libs/log.h"
@@ -366,4 +367,39 @@ FlushInput (void)
FlushInputState (); FlushInputState ();
} }
void
InterrogateInputState (int template, int control, int index, char *buffer, int maxlen)
{
int i;
VCONTROL_GESTURE g;
VControl_StartIter (&ImmediateInputState.key[template][control]);
i = 0;
while (VControl_NextBinding (&g))
{
if (i++ < index)
{
continue;
}
switch (g.type)
{
case VCONTROL_KEY:
snprintf (buffer, maxlen, "%s", VControl_code2name (g.gesture.key));
buffer[maxlen-1] = 0;
break;
case VCONTROL_JOYBUTTON:
snprintf (buffer, maxlen, "[Button %d]", g.gesture.button.index + 1);
buffer[maxlen-1] = 0;
break;
default:
/* Something we don't handle yet */
buffer[0] = 0;
break;
}
return;
}
/* There aren't that many bindings, so return blank string */
buffer[0] = 0;
}
#endif #endif
+64 -5
View File
@@ -28,6 +28,7 @@
#include "libs/graphics/tfb_draw.h" #include "libs/graphics/tfb_draw.h"
#include "libs/strlib.h" #include "libs/strlib.h"
#include "libs/reslib.h" #include "libs/reslib.h"
#include "libs/inplib.h"
#include "libs/sound/sound.h" #include "libs/sound/sound.h"
#include "libs/resource/stringbank.h" #include "libs/resource/stringbank.h"
#include "libs/log.h" #include "libs/log.h"
@@ -75,6 +76,7 @@ static void rename_template (WIDGET_TEXTENTRY *self);
#define BUTTON_COUNT 10 #define BUTTON_COUNT 10
#define LABEL_COUNT 3 #define LABEL_COUNT 3
#define TEXTENTRY_COUNT 1 #define TEXTENTRY_COUNT 1
#define CONTROLENTRY_COUNT 7
/* The space for our widgets */ /* The space for our widgets */
static WIDGET_MENU_SCREEN menus[MENU_COUNT]; static WIDGET_MENU_SCREEN menus[MENU_COUNT];
@@ -83,6 +85,7 @@ static WIDGET_SLIDER sliders[SLIDER_COUNT];
static WIDGET_BUTTON buttons[BUTTON_COUNT]; static WIDGET_BUTTON buttons[BUTTON_COUNT];
static WIDGET_LABEL labels[LABEL_COUNT]; static WIDGET_LABEL labels[LABEL_COUNT];
static WIDGET_TEXTENTRY textentries[TEXTENTRY_COUNT]; static WIDGET_TEXTENTRY textentries[TEXTENTRY_COUNT];
static WIDGET_CONTROLENTRY controlentries[CONTROLENTRY_COUNT];
/* The hardcoded data that isn't strings */ /* The hardcoded data that isn't strings */
@@ -105,7 +108,7 @@ static int menu_sizes[MENU_COUNT] = {
#else #else
4, 4,
#endif #endif
4 11
}; };
static int menu_bgs[MENU_COUNT] = { 0, 1, 1, 2, 3, 1, 2, 1 }; static int menu_bgs[MENU_COUNT] = { 0, 1, 1, 2, 3, 1, 2, 1 };
@@ -167,6 +170,13 @@ static WIDGET *editkeys_widgets[] = {
(WIDGET *)(&choices[20]), (WIDGET *)(&choices[20]),
(WIDGET *)(&labels[2]), (WIDGET *)(&labels[2]),
(WIDGET *)(&textentries[0]), (WIDGET *)(&textentries[0]),
(WIDGET *)(&controlentries[0]),
(WIDGET *)(&controlentries[1]),
(WIDGET *)(&controlentries[2]),
(WIDGET *)(&controlentries[3]),
(WIDGET *)(&controlentries[4]),
(WIDGET *)(&controlentries[5]),
(WIDGET *)(&controlentries[6]),
(WIDGET *)(&buttons[9]) }; (WIDGET *)(&buttons[9]) };
static WIDGET *incomplete_widgets[] = { static WIDGET *incomplete_widgets[] = {
@@ -280,6 +290,23 @@ do_advanced (WIDGET *self, int event)
return FALSE; return FALSE;
} }
static void
populate_editkeys (int template)
{
int i, j;
strncpy (textentries[0].value, input_templates[template].name, textentries[0].maxlen);
textentries[0].value[textentries[0].maxlen-1] = 0;
for (i = 0; i < NUM_KEYS; i++)
{
for (j = 0; j < 2; j++)
{
InterrogateInputState (template, i, j, controlentries[i].controlname[j], WIDGET_CONTROLENTRY_WIDTH);
}
}
}
static int static int
do_editkeys (WIDGET *self, int event) do_editkeys (WIDGET *self, int event)
{ {
@@ -288,8 +315,8 @@ do_editkeys (WIDGET *self, int event)
next = (WIDGET *)(&menus[7]); next = (WIDGET *)(&menus[7]);
/* Prepare the components */ /* Prepare the components */
choices[20].selected = 0; choices[20].selected = 0;
strncpy (textentries[0].value, input_templates[0].name, textentries[0].maxlen);
textentries[0].value[textentries[0].maxlen] = 0; populate_editkeys (0);
(*next->receiveFocus) (next, WIDGET_EVENT_DOWN); (*next->receiveFocus) (next, WIDGET_EVENT_DOWN);
return TRUE; return TRUE;
} }
@@ -300,8 +327,7 @@ do_editkeys (WIDGET *self, int event)
static void static void
change_template (WIDGET_CHOICE *self, int oldval) change_template (WIDGET_CHOICE *self, int oldval)
{ {
strncpy (textentries[0].value, input_templates[self->selected].name, WIDGET_TEXTENTRY_WIDTH); populate_editkeys (self->selected);
textentries[0].value[WIDGET_TEXTENTRY_WIDTH-1] = 0;
} }
static void static void
@@ -574,6 +600,7 @@ init_widgets (void)
for (i = 0; i < MENU_COUNT; i++) for (i = 0; i < MENU_COUNT; i++)
{ {
menus[i].tag = WIDGET_TYPE_MENU_SCREEN;
menus[i].parent = NULL; menus[i].parent = NULL;
menus[i].handleEvent = Widget_HandleEventMenuScreen; menus[i].handleEvent = Widget_HandleEventMenuScreen;
menus[i].receiveFocus = Widget_ReceiveFocusMenuScreen; menus[i].receiveFocus = Widget_ReceiveFocusMenuScreen;
@@ -599,6 +626,7 @@ init_widgets (void)
for (i = 0; i < CHOICE_COUNT; i++) for (i = 0; i < CHOICE_COUNT; i++)
{ {
choices[i].tag = WIDGET_TYPE_CHOICE;
choices[i].parent = NULL; choices[i].parent = NULL;
choices[i].handleEvent = Widget_HandleEventChoice; choices[i].handleEvent = Widget_HandleEventChoice;
choices[i].receiveFocus = Widget_ReceiveFocusChoice; choices[i].receiveFocus = Widget_ReceiveFocusChoice;
@@ -688,6 +716,7 @@ init_widgets (void)
for (i = 0; i < SLIDER_COUNT; i++) for (i = 0; i < SLIDER_COUNT; i++)
{ {
sliders[i].tag = WIDGET_TYPE_SLIDER;
sliders[i].parent = NULL; sliders[i].parent = NULL;
sliders[i].handleEvent = Widget_HandleEventSlider; sliders[i].handleEvent = Widget_HandleEventSlider;
sliders[i].receiveFocus = Widget_ReceiveFocusSimple; sliders[i].receiveFocus = Widget_ReceiveFocusSimple;
@@ -742,6 +771,7 @@ init_widgets (void)
for (i = 0; i < BUTTON_COUNT; i++) for (i = 0; i < BUTTON_COUNT; i++)
{ {
buttons[i].tag = WIDGET_TYPE_BUTTON;
buttons[i].parent = NULL; buttons[i].parent = NULL;
buttons[i].handleEvent = button_handlers[i]; buttons[i].handleEvent = button_handlers[i];
buttons[i].receiveFocus = Widget_ReceiveFocusSimple; buttons[i].receiveFocus = Widget_ReceiveFocusSimple;
@@ -791,6 +821,7 @@ init_widgets (void)
for (i = 0; i < LABEL_COUNT; i++) for (i = 0; i < LABEL_COUNT; i++)
{ {
labels[i].tag = WIDGET_TYPE_LABEL;
labels[i].parent = NULL; labels[i].parent = NULL;
labels[i].handleEvent = Widget_HandleEventIgnoreAll; labels[i].handleEvent = Widget_HandleEventIgnoreAll;
labels[i].receiveFocus = Widget_ReceiveFocusRefuseFocus; labels[i].receiveFocus = Widget_ReceiveFocusRefuseFocus;
@@ -834,6 +865,7 @@ init_widgets (void)
} }
for (i = 0; i < TEXTENTRY_COUNT; i++) for (i = 0; i < TEXTENTRY_COUNT; i++)
{ {
textentries[i].tag = WIDGET_TYPE_TEXTENTRY;
textentries[i].parent = NULL; textentries[i].parent = NULL;
textentries[i].handleEvent = Widget_HandleEventTextEntry; textentries[i].handleEvent = Widget_HandleEventTextEntry;
textentries[i].receiveFocus = Widget_ReceiveFocusSimple; textentries[i].receiveFocus = Widget_ReceiveFocusSimple;
@@ -867,6 +899,33 @@ init_widgets (void)
} }
textentries[0].onChange = rename_template; textentries[0].onChange = rename_template;
/* Control Entry boxes */
if (index >= count)
{
log_add (log_Fatal, "PANIC: String table cut short while reading control entries");
exit (EXIT_FAILURE);
}
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, index++)), '\n', 100, buffer, bank) != CONTROLENTRY_COUNT)
{
log_add (log_Fatal, "PANIC: Incorrect number of Control Entries");
exit (EXIT_FAILURE);
}
for (i = 0; i < CONTROLENTRY_COUNT; i++)
{
controlentries[i].tag = WIDGET_TYPE_CONTROLENTRY;
controlentries[i].parent = NULL;
controlentries[i].handleEvent = Widget_HandleEventControlEntry;
controlentries[i].receiveFocus = Widget_ReceiveFocusControlEntry;
controlentries[i].draw = Widget_DrawControlEntry;
controlentries[i].height = Widget_HeightOneLine;
controlentries[i].width = Widget_WidthFullScreen;
controlentries[i].category = buffer[i];
controlentries[i].highlighted = 0;
controlentries[i].controlname[0][0] = 0;
controlentries[i].controlname[0][1] = 0;
}
/* Check for garbage at the end */ /* Check for garbage at the end */
if (index < count) if (index < count)
{ {
+6 -6
View File
@@ -361,7 +361,7 @@ main (int argc, char *argv[])
} }
else else
{ {
strcpy (input_templates[0].name, "Keyboard 1"); strcpy (input_templates[0].name, "Arrows");
res_PutString ("config.keys.1.name", input_templates[0].name); res_PutString ("config.keys.1.name", input_templates[0].name);
} }
if (res_HasKey ("config.keys.2.name")) if (res_HasKey ("config.keys.2.name"))
@@ -371,7 +371,7 @@ main (int argc, char *argv[])
} }
else else
{ {
strcpy (input_templates[1].name, "Keyboard 2"); strcpy (input_templates[1].name, "WASD");
res_PutString ("config.keys.2.name", input_templates[1].name); res_PutString ("config.keys.2.name", input_templates[1].name);
} }
if (res_HasKey ("config.keys.3.name")) if (res_HasKey ("config.keys.3.name"))
@@ -381,7 +381,7 @@ main (int argc, char *argv[])
} }
else else
{ {
strcpy (input_templates[2].name, "Keyboard 3"); strcpy (input_templates[2].name, "Arrows (2)");
res_PutString ("config.keys.3.name", input_templates[2].name); res_PutString ("config.keys.3.name", input_templates[2].name);
} }
if (res_HasKey ("config.keys.4.name")) if (res_HasKey ("config.keys.4.name"))
@@ -391,7 +391,7 @@ main (int argc, char *argv[])
} }
else else
{ {
strcpy (input_templates[3].name, "Joystick 1"); strcpy (input_templates[3].name, "ESDF");
res_PutString ("config.keys.4.name", input_templates[3].name); res_PutString ("config.keys.4.name", input_templates[3].name);
} }
if (res_HasKey ("config.keys.5.name")) if (res_HasKey ("config.keys.5.name"))
@@ -401,7 +401,7 @@ main (int argc, char *argv[])
} }
else else
{ {
strcpy (input_templates[4].name, "Joystick 2"); strcpy (input_templates[4].name, "Joystick 1");
res_PutString ("config.keys.5.name", input_templates[4].name); res_PutString ("config.keys.5.name", input_templates[4].name);
} }
if (res_HasKey ("config.keys.6.name")) if (res_HasKey ("config.keys.6.name"))
@@ -411,7 +411,7 @@ main (int argc, char *argv[])
} }
else else
{ {
strcpy (input_templates[5].name, "Joystick 3"); strcpy (input_templates[5].name, "Joystick 2");
res_PutString ("config.keys.6.name", input_templates[5].name); res_PutString ("config.keys.6.name", input_templates[5].name);
} }