Content-driven Setup Menu Strings.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2301 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
Changes towards version 0.6:
|
Changes towards version 0.6:
|
||||||
|
- Setup menu reads strings out of lbm/setupmenu.txt - Michael
|
||||||
- More fixes towards working 64-bits binaries.
|
- More fixes towards working 64-bits binaries.
|
||||||
- Flashing outfit modules to build w/ PC menus too; bug #871 - Alex
|
- Flashing outfit modules to build w/ PC menus too; bug #871 - Alex
|
||||||
- Corrected caption Orbit: to Tilt: in planet scan; bug #847 - Alex
|
- Corrected caption Orbit: to Tilt: in planet scan; bug #847 - Alex
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Ur-Quan Masters Setup
|
|||||||
Graphics Options
|
Graphics Options
|
||||||
Audio Options
|
Audio Options
|
||||||
3do/PC Options
|
3do/PC Options
|
||||||
Addon Packs
|
Resources Options
|
||||||
Controls Setup
|
Controls Setup
|
||||||
Advanced Options
|
Advanced Options
|
||||||
|
|
||||||
@@ -185,11 +185,12 @@ PC
|
|||||||
#(CAT_9_OPT_0_DESC)
|
#(CAT_9_OPT_0_DESC)
|
||||||
Uses the music from the Original PC version.
|
Uses the music from the Original PC version.
|
||||||
Prefers .MOD files to .OGG files.
|
Prefers .MOD files to .OGG files.
|
||||||
|
Requires a restart of UQM to take effect.
|
||||||
|
|
||||||
#(CAT_9_OPT_1_DESC)
|
#(CAT_9_OPT_1_DESC)
|
||||||
Uses the music from the 3do version and/or the
|
Uses more modern music, if available.
|
||||||
Ur-Quan Masters Remix Project, if available.
|
Prefers .OGG files to .MOD files.
|
||||||
Prefers .OGG files over .MOD.
|
Requires a restart of UQM to take effect.
|
||||||
|
|
||||||
#(CAT_10_OPTS)
|
#(CAT_10_OPTS)
|
||||||
Windowed
|
Windowed
|
||||||
@@ -255,12 +256,18 @@ OpenAL
|
|||||||
|
|
||||||
#(CAT_15_OPT_0_DESC)
|
#(CAT_15_OPT_0_DESC)
|
||||||
Play silently.
|
Play silently.
|
||||||
|
This option will not take effect until
|
||||||
|
you restart UQM.
|
||||||
|
|
||||||
#(CAT_15_OPT_1_DESC)
|
#(CAT_15_OPT_1_DESC)
|
||||||
Use the default audio mixer.
|
Use the default audio mixer.
|
||||||
|
This option will not take effect until
|
||||||
|
you restart UQM.
|
||||||
|
|
||||||
#(CAT_15_OPT_2_DESC)
|
#(CAT_15_OPT_2_DESC)
|
||||||
Use the Creative Labs OpenAL driver.
|
Use the Creative Labs OpenAL driver.
|
||||||
|
This option will not take effect until
|
||||||
|
you restart UQM.
|
||||||
|
|
||||||
#(CAT_16_OPTS)
|
#(CAT_16_OPTS)
|
||||||
Low
|
Low
|
||||||
@@ -269,13 +276,18 @@ High
|
|||||||
|
|
||||||
#(CAT_16_OPT_0_DESC)
|
#(CAT_16_OPT_0_DESC)
|
||||||
Low audio quality.
|
Low audio quality.
|
||||||
|
This option will not take effect until
|
||||||
|
you restart UQM.
|
||||||
|
|
||||||
#(CAT_16_OPT_1_DESC)
|
#(CAT_16_OPT_1_DESC)
|
||||||
Medium audio quality.
|
Medium audio quality.
|
||||||
|
This option will not take effect until
|
||||||
|
you restart UQM.
|
||||||
|
|
||||||
#(CAT_16_OPT_2_DESC)
|
#(CAT_16_OPT_2_DESC)
|
||||||
Highest audio quality.
|
Highest audio quality.
|
||||||
May not work on all architectures.
|
This option will not take effect until
|
||||||
|
you restart UQM.
|
||||||
|
|
||||||
#(CAT_17_OPTS)
|
#(CAT_17_OPTS)
|
||||||
Static
|
Static
|
||||||
|
|||||||
@@ -142,29 +142,4 @@ void Widget_DrawSlider (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);
|
||||||
|
|
||||||
/* "Constructor" macros */
|
|
||||||
|
|
||||||
#define BUTTON_INIT(handler, name, ttip1, ttip2, ttip3) { \
|
|
||||||
NULL, handler, Widget_ReceiveFocusSimple, Widget_DrawButton, \
|
|
||||||
Widget_HeightOneLine, Widget_WidthFullScreen, \
|
|
||||||
(name), { (ttip1), (ttip2), (ttip3) } }
|
|
||||||
|
|
||||||
#define CHOICE_PREFACE NULL, Widget_HandleEventChoice, \
|
|
||||||
Widget_ReceiveFocusChoice, Widget_DrawChoice, \
|
|
||||||
Widget_HeightChoice, Widget_WidthFullScreen
|
|
||||||
|
|
||||||
#define LABEL_PREFACE NULL, Widget_HandleEventIgnoreAll, \
|
|
||||||
Widget_ReceiveFocusRefuseFocus, Widget_DrawLabel, \
|
|
||||||
Widget_HeightLabel, Widget_WidthFullScreen
|
|
||||||
|
|
||||||
#define MENU_SCREEN_PREFACE NULL, Widget_HandleEventMenuScreen, \
|
|
||||||
Widget_ReceiveFocusMenuScreen, \
|
|
||||||
Widget_DrawMenuScreen, Widget_HeightFullScreen, \
|
|
||||||
Widget_WidthFullScreen
|
|
||||||
|
|
||||||
#define SLIDER_PREFACE NULL, Widget_HandleEventSlider, \
|
|
||||||
Widget_ReceiveFocusSimple, Widget_DrawSlider, \
|
|
||||||
Widget_HeightOneLine, Widget_WidthFullScreen, \
|
|
||||||
Widget_Slider_DrawValue
|
|
||||||
|
|
||||||
#endif /* _WIDGETS_H */
|
#endif /* _WIDGETS_H */
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "libs/reslib.h"
|
#include "libs/reslib.h"
|
||||||
#include "alist.h"
|
#include "alist.h"
|
||||||
#include "stringbank.h"
|
|
||||||
|
|
||||||
alist_entry *
|
alist_entry *
|
||||||
AlistEntry_New (const char *key, const char *value)
|
AlistEntry_New (const char *key, const char *value)
|
||||||
@@ -48,6 +47,7 @@ Alist_New (void)
|
|||||||
{
|
{
|
||||||
alist *result = malloc (sizeof(alist));
|
alist *result = malloc (sizeof(alist));
|
||||||
result->first = NULL;
|
result->first = NULL;
|
||||||
|
result->bank = StringBank_Create ();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +55,7 @@ void
|
|||||||
Alist_Free (alist *m) {
|
Alist_Free (alist *m) {
|
||||||
if (m == NULL) return;
|
if (m == NULL) return;
|
||||||
AlistEntry_Free (m->first);
|
AlistEntry_Free (m->first);
|
||||||
|
StringBank_Free (m->bank);
|
||||||
free (m);
|
free (m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,8 +199,8 @@ Alist_New_FromString (char *d)
|
|||||||
make a new map entry. */
|
make a new map entry. */
|
||||||
d[key_end] = '\0';
|
d[key_end] = '\0';
|
||||||
d[value_end] = '\0';
|
d[value_end] = '\0';
|
||||||
Alist_PutString (m, StringBank_AddOrFindString(d+key_start),
|
Alist_PutString (m, StringBank_AddOrFindString(m->bank, d+key_start),
|
||||||
StringBank_AddOrFindString(d+value_start));
|
StringBank_AddOrFindString(m->bank, d+value_start));
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#define _ALIST_H_
|
#define _ALIST_H_
|
||||||
|
|
||||||
#include "libs/uio.h"
|
#include "libs/uio.h"
|
||||||
|
#include "stringbank.h"
|
||||||
|
|
||||||
/* Associative List types. */
|
/* Associative List types. */
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ typedef struct _alist_entry {
|
|||||||
|
|
||||||
typedef struct _alist_map {
|
typedef struct _alist_map {
|
||||||
alist_entry *first;
|
alist_entry *first;
|
||||||
|
stringbank *bank;
|
||||||
} alist;
|
} alist;
|
||||||
|
|
||||||
/* ***** alist_entry operations ***** */
|
/* ***** alist_entry operations ***** */
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ static const char *
|
|||||||
int2str (int i) {
|
int2str (int i) {
|
||||||
char buf[20];
|
char buf[20];
|
||||||
sprintf (buf, "%d", i);
|
sprintf (buf, "%d", i);
|
||||||
return StringBank_AddOrFindString (buf);
|
return StringBank_AddOrFindString (map->bank, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|||||||
@@ -22,55 +22,69 @@
|
|||||||
|
|
||||||
#include "stringbank.h"
|
#include "stringbank.h"
|
||||||
|
|
||||||
#define CHUNK_SIZE (1024 - sizeof (void *) - sizeof (int))
|
typedef stringbank chunk;
|
||||||
|
|
||||||
typedef struct _stringbank_chunk {
|
static stringbank *
|
||||||
char data[CHUNK_SIZE];
|
add_chunk (stringbank *bank)
|
||||||
int len;
|
|
||||||
struct _stringbank_chunk *next;
|
|
||||||
} chunk;
|
|
||||||
|
|
||||||
static chunk *bank = NULL;
|
|
||||||
|
|
||||||
static void
|
|
||||||
add_chunk (void)
|
|
||||||
{
|
{
|
||||||
chunk *n = malloc (sizeof (chunk));
|
stringbank *n = malloc (sizeof (stringbank));
|
||||||
n->len = 0;
|
n->len = 0;
|
||||||
n->next = bank;
|
n->next = NULL;
|
||||||
bank = n;
|
if (bank)
|
||||||
|
{
|
||||||
|
while (bank->next)
|
||||||
|
bank = bank->next;
|
||||||
|
bank->next = n;
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
stringbank *
|
||||||
|
StringBank_Create (void)
|
||||||
|
{
|
||||||
|
return add_chunk (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StringBank_Free (stringbank *bank)
|
||||||
|
{
|
||||||
|
if (bank)
|
||||||
|
{
|
||||||
|
StringBank_Free (bank->next);
|
||||||
|
free (bank);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
StringBank_AddString (const char *str)
|
StringBank_AddString (stringbank *bank, const char *str)
|
||||||
{
|
{
|
||||||
int len = strlen (str);
|
unsigned int len = strlen (str) + 1;
|
||||||
chunk *x = bank;
|
stringbank *x = bank;
|
||||||
if (len > CHUNK_SIZE)
|
if (len > STRBANK_CHUNK_SIZE)
|
||||||
return NULL;
|
return NULL;
|
||||||
while (x) {
|
while (x) {
|
||||||
int remaining = CHUNK_SIZE - x->len;
|
unsigned int remaining = STRBANK_CHUNK_SIZE - x->len;
|
||||||
if (len < remaining) {
|
if (len < remaining) {
|
||||||
char *result = x->data + x->len;
|
char *result = x->data + x->len;
|
||||||
strcpy (result, str);
|
strcpy (result, str);
|
||||||
x->len += len + 1;
|
x->len += len;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
x = x->next;
|
x = x->next;
|
||||||
}
|
}
|
||||||
/* No room in any currently existing chunk */
|
/* No room in any currently existing chunk */
|
||||||
add_chunk ();
|
x = add_chunk (bank);
|
||||||
strcpy (bank->data, str);
|
strcpy (x->data, str);
|
||||||
bank->len += len + 1;
|
x->len += len + 1;
|
||||||
return bank->data;
|
return x->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
StringBank_AddOrFindString (const char *str)
|
StringBank_AddOrFindString (stringbank *bank, const char *str)
|
||||||
{
|
{
|
||||||
int len = strlen (str);
|
unsigned int len = strlen (str) + 1;
|
||||||
chunk *x = bank;
|
stringbank *x = bank;
|
||||||
if (len > CHUNK_SIZE)
|
if (len > STRBANK_CHUNK_SIZE)
|
||||||
return NULL;
|
return NULL;
|
||||||
while (x) {
|
while (x) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -83,15 +97,76 @@ StringBank_AddOrFindString (const char *str)
|
|||||||
x = x->next;
|
x = x->next;
|
||||||
}
|
}
|
||||||
/* We didn't find it, so add it */
|
/* We didn't find it, so add it */
|
||||||
return StringBank_AddString (str);
|
return StringBank_AddString (bank, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
static char buffer[STRBANK_CHUNK_SIZE];
|
||||||
|
|
||||||
|
const char *
|
||||||
|
StringBank_AddSubstring (stringbank *bank, const char *str, unsigned int n)
|
||||||
|
{
|
||||||
|
unsigned int len = strlen (str);
|
||||||
|
if (n > len)
|
||||||
|
{
|
||||||
|
return StringBank_AddString (bank, str);
|
||||||
|
}
|
||||||
|
if (n >= STRBANK_CHUNK_SIZE)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
strncpy (buffer, str, n);
|
||||||
|
buffer[n] = '\0';
|
||||||
|
return StringBank_AddString(bank, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
StringBank_AddOrFindSubstring (stringbank *bank, const char *str, unsigned int n)
|
||||||
|
{
|
||||||
|
unsigned int len = strlen (str);
|
||||||
|
if (n > len)
|
||||||
|
{
|
||||||
|
return StringBank_AddOrFindString (bank, str);
|
||||||
|
}
|
||||||
|
if (n >= STRBANK_CHUNK_SIZE)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
strncpy (buffer, str, n);
|
||||||
|
buffer[n] = '\0';
|
||||||
|
return StringBank_AddOrFindString(bank, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
SplitString (const char *s, char splitchar, int n, const char **result, stringbank *bank)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
const char *index = s;
|
||||||
|
|
||||||
|
for (i = 0; i < n-1; i++)
|
||||||
|
{
|
||||||
|
const char *next;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
next = strchr (index, splitchar);
|
||||||
|
if (!next)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = next - index;
|
||||||
|
result[i] = StringBank_AddOrFindSubstring (bank, index, len);
|
||||||
|
index = next+1;
|
||||||
|
}
|
||||||
|
result[i] = StringBank_AddOrFindString (bank, index);
|
||||||
|
return i+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SB_DEBUG
|
||||||
|
|
||||||
void
|
void
|
||||||
StringBank_Dump (FILE *s)
|
StringBank_Dump (stringbank *bank, FILE *s)
|
||||||
{
|
{
|
||||||
chunk *x = bank;
|
stringbank *x = bank;
|
||||||
while (x) {
|
while (x) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < x->len) {
|
while (i < x->len) {
|
||||||
|
|||||||
@@ -19,19 +19,39 @@
|
|||||||
#ifndef _STRINGBANK_H_
|
#ifndef _STRINGBANK_H_
|
||||||
#define _STRINGBANK_H_
|
#define _STRINGBANK_H_
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef SB_DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Put str into the string bank. */
|
#define STRBANK_CHUNK_SIZE (1024 - sizeof (void *) - sizeof (int))
|
||||||
const char *StringBank_AddString (const char *str);
|
|
||||||
|
|
||||||
/* Put str into the string bank if it's not already there. Much slower. */
|
typedef struct _stringbank_chunk {
|
||||||
const char *StringBank_AddOrFindString (const char *str);
|
char data[STRBANK_CHUNK_SIZE];
|
||||||
|
int len;
|
||||||
|
struct _stringbank_chunk *next;
|
||||||
|
} stringbank;
|
||||||
|
|
||||||
#ifdef DEBUG
|
/* Constructors and destructors */
|
||||||
|
stringbank *StringBank_Create (void);
|
||||||
|
void StringBank_Free (stringbank *bank);
|
||||||
|
|
||||||
|
/* Put str or n chars after str into the string bank. */
|
||||||
|
const char *StringBank_AddString (stringbank *bank, const char *str);
|
||||||
|
const char *StringBank_AddSubstring (stringbank *bank, const char *str, unsigned int n);
|
||||||
|
|
||||||
|
/* Put str or n chars after str into the string bank if it's not already
|
||||||
|
there. Much slower. */
|
||||||
|
const char *StringBank_AddOrFindString (stringbank *bank, const char *str);
|
||||||
|
const char *StringBank_AddOrFindSubstring (stringbank *bank, const char *str, unsigned int n);
|
||||||
|
|
||||||
|
/* Split a string s into at most n substrings, separated by splitchar.
|
||||||
|
Pointers to these substrings will be stored in result; the
|
||||||
|
substrings themselves will be filed in the specified stringbank. */
|
||||||
|
int SplitString (const char *s, char splitchar, int n, const char **result, stringbank *bank);
|
||||||
|
|
||||||
|
#ifdef SB_DEBUG
|
||||||
/* Print out a list of the contents of the string bank to the named stream. */
|
/* Print out a list of the contents of the string bank to the named stream. */
|
||||||
void StringBank_Dump (FILE *s);
|
void StringBank_Dump (stringbank *bank, FILE *s);
|
||||||
#endif /* DEBUG */
|
#endif /* SB_DEBUG */
|
||||||
|
|
||||||
#endif /* _STRINGBANK_H_ */
|
#endif /* _STRINGBANK_H_ */
|
||||||
|
|||||||
+444
-464
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user