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:
|
||||
- Setup menu reads strings out of lbm/setupmenu.txt - Michael
|
||||
- More fixes towards working 64-bits binaries.
|
||||
- Flashing outfit modules to build w/ PC menus too; bug #871 - Alex
|
||||
- Corrected caption Orbit: to Tilt: in planet scan; bug #847 - Alex
|
||||
|
||||
@@ -6,7 +6,7 @@ Ur-Quan Masters Setup
|
||||
Graphics Options
|
||||
Audio Options
|
||||
3do/PC Options
|
||||
Addon Packs
|
||||
Resources Options
|
||||
Controls Setup
|
||||
Advanced Options
|
||||
|
||||
@@ -185,11 +185,12 @@ PC
|
||||
#(CAT_9_OPT_0_DESC)
|
||||
Uses the music from the Original PC version.
|
||||
Prefers .MOD files to .OGG files.
|
||||
Requires a restart of UQM to take effect.
|
||||
|
||||
#(CAT_9_OPT_1_DESC)
|
||||
Uses the music from the 3do version and/or the
|
||||
Ur-Quan Masters Remix Project, if available.
|
||||
Prefers .OGG files over .MOD.
|
||||
Uses more modern music, if available.
|
||||
Prefers .OGG files to .MOD files.
|
||||
Requires a restart of UQM to take effect.
|
||||
|
||||
#(CAT_10_OPTS)
|
||||
Windowed
|
||||
@@ -255,12 +256,18 @@ OpenAL
|
||||
|
||||
#(CAT_15_OPT_0_DESC)
|
||||
Play silently.
|
||||
This option will not take effect until
|
||||
you restart UQM.
|
||||
|
||||
#(CAT_15_OPT_1_DESC)
|
||||
Use the default audio mixer.
|
||||
This option will not take effect until
|
||||
you restart UQM.
|
||||
|
||||
#(CAT_15_OPT_2_DESC)
|
||||
Use the Creative Labs OpenAL driver.
|
||||
This option will not take effect until
|
||||
you restart UQM.
|
||||
|
||||
#(CAT_16_OPTS)
|
||||
Low
|
||||
@@ -269,13 +276,18 @@ High
|
||||
|
||||
#(CAT_16_OPT_0_DESC)
|
||||
Low audio quality.
|
||||
This option will not take effect until
|
||||
you restart UQM.
|
||||
|
||||
#(CAT_16_OPT_1_DESC)
|
||||
Medium audio quality.
|
||||
This option will not take effect until
|
||||
you restart UQM.
|
||||
|
||||
#(CAT_16_OPT_2_DESC)
|
||||
Highest audio quality.
|
||||
May not work on all architectures.
|
||||
This option will not take effect until
|
||||
you restart UQM.
|
||||
|
||||
#(CAT_17_OPTS)
|
||||
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);
|
||||
|
||||
/* "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 */
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <ctype.h>
|
||||
#include "libs/reslib.h"
|
||||
#include "alist.h"
|
||||
#include "stringbank.h"
|
||||
|
||||
alist_entry *
|
||||
AlistEntry_New (const char *key, const char *value)
|
||||
@@ -48,6 +47,7 @@ Alist_New (void)
|
||||
{
|
||||
alist *result = malloc (sizeof(alist));
|
||||
result->first = NULL;
|
||||
result->bank = StringBank_Create ();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ void
|
||||
Alist_Free (alist *m) {
|
||||
if (m == NULL) return;
|
||||
AlistEntry_Free (m->first);
|
||||
StringBank_Free (m->bank);
|
||||
free (m);
|
||||
}
|
||||
|
||||
@@ -198,8 +199,8 @@ Alist_New_FromString (char *d)
|
||||
make a new map entry. */
|
||||
d[key_end] = '\0';
|
||||
d[value_end] = '\0';
|
||||
Alist_PutString (m, StringBank_AddOrFindString(d+key_start),
|
||||
StringBank_AddOrFindString(d+value_start));
|
||||
Alist_PutString (m, StringBank_AddOrFindString(m->bank, d+key_start),
|
||||
StringBank_AddOrFindString(m->bank, d+value_start));
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define _ALIST_H_
|
||||
|
||||
#include "libs/uio.h"
|
||||
#include "stringbank.h"
|
||||
|
||||
/* Associative List types. */
|
||||
|
||||
@@ -30,6 +31,7 @@ typedef struct _alist_entry {
|
||||
|
||||
typedef struct _alist_map {
|
||||
alist_entry *first;
|
||||
stringbank *bank;
|
||||
} alist;
|
||||
|
||||
/* ***** alist_entry operations ***** */
|
||||
|
||||
@@ -53,7 +53,7 @@ static const char *
|
||||
int2str (int i) {
|
||||
char buf[20];
|
||||
sprintf (buf, "%d", i);
|
||||
return StringBank_AddOrFindString (buf);
|
||||
return StringBank_AddOrFindString (map->bank, buf);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -22,55 +22,69 @@
|
||||
|
||||
#include "stringbank.h"
|
||||
|
||||
#define CHUNK_SIZE (1024 - sizeof (void *) - sizeof (int))
|
||||
typedef stringbank chunk;
|
||||
|
||||
typedef struct _stringbank_chunk {
|
||||
char data[CHUNK_SIZE];
|
||||
int len;
|
||||
struct _stringbank_chunk *next;
|
||||
} chunk;
|
||||
|
||||
static chunk *bank = NULL;
|
||||
|
||||
static void
|
||||
add_chunk (void)
|
||||
static stringbank *
|
||||
add_chunk (stringbank *bank)
|
||||
{
|
||||
chunk *n = malloc (sizeof (chunk));
|
||||
stringbank *n = malloc (sizeof (stringbank));
|
||||
n->len = 0;
|
||||
n->next = bank;
|
||||
bank = n;
|
||||
n->next = NULL;
|
||||
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 *
|
||||
StringBank_AddString (const char *str)
|
||||
StringBank_AddString (stringbank *bank, const char *str)
|
||||
{
|
||||
int len = strlen (str);
|
||||
chunk *x = bank;
|
||||
if (len > CHUNK_SIZE)
|
||||
unsigned int len = strlen (str) + 1;
|
||||
stringbank *x = bank;
|
||||
if (len > STRBANK_CHUNK_SIZE)
|
||||
return NULL;
|
||||
while (x) {
|
||||
int remaining = CHUNK_SIZE - x->len;
|
||||
unsigned int remaining = STRBANK_CHUNK_SIZE - x->len;
|
||||
if (len < remaining) {
|
||||
char *result = x->data + x->len;
|
||||
strcpy (result, str);
|
||||
x->len += len + 1;
|
||||
x->len += len;
|
||||
return result;
|
||||
}
|
||||
x = x->next;
|
||||
}
|
||||
/* No room in any currently existing chunk */
|
||||
add_chunk ();
|
||||
strcpy (bank->data, str);
|
||||
bank->len += len + 1;
|
||||
return bank->data;
|
||||
x = add_chunk (bank);
|
||||
strcpy (x->data, str);
|
||||
x->len += len + 1;
|
||||
return x->data;
|
||||
}
|
||||
|
||||
const char *
|
||||
StringBank_AddOrFindString (const char *str)
|
||||
StringBank_AddOrFindString (stringbank *bank, const char *str)
|
||||
{
|
||||
int len = strlen (str);
|
||||
chunk *x = bank;
|
||||
if (len > CHUNK_SIZE)
|
||||
unsigned int len = strlen (str) + 1;
|
||||
stringbank *x = bank;
|
||||
if (len > STRBANK_CHUNK_SIZE)
|
||||
return NULL;
|
||||
while (x) {
|
||||
int i = 0;
|
||||
@@ -83,15 +97,76 @@ StringBank_AddOrFindString (const char *str)
|
||||
x = x->next;
|
||||
}
|
||||
/* 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
|
||||
StringBank_Dump (FILE *s)
|
||||
StringBank_Dump (stringbank *bank, FILE *s)
|
||||
{
|
||||
chunk *x = bank;
|
||||
stringbank *x = bank;
|
||||
while (x) {
|
||||
int i = 0;
|
||||
while (i < x->len) {
|
||||
|
||||
@@ -19,19 +19,39 @@
|
||||
#ifndef _STRINGBANK_H_
|
||||
#define _STRINGBANK_H_
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef SB_DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/* Put str into the string bank. */
|
||||
const char *StringBank_AddString (const char *str);
|
||||
#define STRBANK_CHUNK_SIZE (1024 - sizeof (void *) - sizeof (int))
|
||||
|
||||
/* Put str into the string bank if it's not already there. Much slower. */
|
||||
const char *StringBank_AddOrFindString (const char *str);
|
||||
typedef struct _stringbank_chunk {
|
||||
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. */
|
||||
void StringBank_Dump (FILE *s);
|
||||
#endif /* DEBUG */
|
||||
void StringBank_Dump (stringbank *bank, FILE *s);
|
||||
#endif /* SB_DEBUG */
|
||||
|
||||
#endif /* _STRINGBANK_H_ */
|
||||
|
||||
+444
-464
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user