Implemented the mp_config stubs.
Fixed a small error with menus (wrong font size was being used in RenderMenuElement -- was visible with custom maps with long names).
This commit is contained in:
parent
5e99463577
commit
84e9c736f3
3 changed files with 100 additions and 114 deletions
|
@ -988,7 +988,6 @@ static void SetupNewMenu(enum AVPMENU_ID menuID)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case AVPMENU_MULTIPLAYER_LOADCONFIG :
|
case AVPMENU_MULTIPLAYER_LOADCONFIG :
|
||||||
{
|
{
|
||||||
extern AVPMENU_ELEMENT* AvPMenu_Multiplayer_LoadConfig;
|
extern AVPMENU_ELEMENT* AvPMenu_Multiplayer_LoadConfig;
|
||||||
|
@ -3213,16 +3212,19 @@ static void InteractWithMenuElement(enum AVPMENU_ELEMENT_INTERACTION_ID interact
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int LengthOfMenuText(char *textPtr);
|
||||||
|
int LengthOfSmallMenuText(char *textPtr);
|
||||||
|
|
||||||
static void RenderMenuElement(AVPMENU_ELEMENT *elementPtr, int e, int y)
|
static void RenderMenuElement(AVPMENU_ELEMENT *elementPtr, int e, int y)
|
||||||
{
|
{
|
||||||
int (*RenderText)(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID format);
|
int (*RenderText)(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID format);
|
||||||
int (*RenderText_Coloured)(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID format, int r, int g, int b);
|
int (*RenderText_Coloured)(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID format, int r, int g, int b);
|
||||||
|
int (*MenuTextLength)(char *textPtr);
|
||||||
|
|
||||||
if (AvPMenus.FontToUse==AVPMENU_FONT_BIG)
|
if (AvPMenus.FontToUse==AVPMENU_FONT_BIG)
|
||||||
{
|
{
|
||||||
RenderText = RenderMenuText;
|
RenderText = RenderMenuText;
|
||||||
|
MenuTextLength = LengthOfMenuText;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3237,6 +3239,7 @@ static void RenderMenuElement(AVPMENU_ELEMENT *elementPtr, int e, int y)
|
||||||
RenderText = RenderSmallMenuText;
|
RenderText = RenderSmallMenuText;
|
||||||
RenderText_Coloured = RenderSmallMenuText_Coloured;
|
RenderText_Coloured = RenderSmallMenuText_Coloured;
|
||||||
}
|
}
|
||||||
|
MenuTextLength = LengthOfSmallMenuText;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(elementPtr->ElementID)
|
switch(elementPtr->ElementID)
|
||||||
|
@ -3339,9 +3342,9 @@ static void RenderMenuElement(AVPMENU_ELEMENT *elementPtr, int e, int y)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int length = LengthOfMenuText(textPtr);
|
int length = MenuTextLength(textPtr);
|
||||||
|
|
||||||
if (length>ScreenDescriptorBlock.SDB_Width-MENU_CENTREX-MENU_ELEMENT_SPACING*2)
|
if (length>(ScreenDescriptorBlock.SDB_Width-MENU_CENTREX-MENU_ELEMENT_SPACING*2))
|
||||||
{
|
{
|
||||||
RenderText
|
RenderText
|
||||||
(
|
(
|
||||||
|
|
|
@ -15,6 +15,12 @@
|
||||||
#define UseLocalAssert Yes
|
#define UseLocalAssert Yes
|
||||||
#include "ourasert.h"
|
#include "ourasert.h"
|
||||||
|
|
||||||
|
#include <glob.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
extern void SetDefaultMultiplayerConfig();
|
extern void SetDefaultMultiplayerConfig();
|
||||||
|
@ -24,7 +30,7 @@ extern char MP_Config_Description[];
|
||||||
#define MP_CONFIG_DIR "MPConfig"
|
#define MP_CONFIG_DIR "MPConfig"
|
||||||
#define MP_CONFIG_WILDCARD "MPConfig/*.cfg"
|
#define MP_CONFIG_WILDCARD "MPConfig/*.cfg"
|
||||||
|
|
||||||
#define SKIRMISH_CONFIG_WILDCARD "MPConfig/.skirmish_cfg"
|
#define SKIRMISH_CONFIG_WILDCARD "MPConfig/*.skirmish_cfg"
|
||||||
|
|
||||||
static List<char*> ConfigurationFilenameList;
|
static List<char*> ConfigurationFilenameList;
|
||||||
static List<char*> ConfigurationLocalisedFilenameList;
|
static List<char*> ConfigurationLocalisedFilenameList;
|
||||||
|
@ -57,17 +63,9 @@ BOOL BuildLoadMPConfigMenu()
|
||||||
load_name=SKIRMISH_CONFIG_WILDCARD;
|
load_name=SKIRMISH_CONFIG_WILDCARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "STUB: BuildLoadMPConfigMenu()\n");
|
glob_t globbuf;
|
||||||
#if 0
|
if (glob(load_name, 0, NULL, &globbuf))
|
||||||
// allow a wildcard search
|
|
||||||
WIN32_FIND_DATA wfd;
|
|
||||||
|
|
||||||
HANDLE hFindFile = ::FindFirstFile(load_name,&wfd);
|
|
||||||
|
|
||||||
if (INVALID_HANDLE_VALUE == hFindFile)
|
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
// get any path in the load_name
|
// get any path in the load_name
|
||||||
int nPathLen = 0;
|
int nPathLen = 0;
|
||||||
|
@ -85,22 +83,25 @@ BOOL BuildLoadMPConfigMenu()
|
||||||
int nLen = pSlash - load_name + 1;
|
int nLen = pSlash - load_name + 1;
|
||||||
if (nLen > nPathLen) nPathLen = nLen;
|
if (nLen > nPathLen) nPathLen = nLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
for (unsigned int i = 0; i < globbuf.gl_pathc; i++) {
|
||||||
{
|
struct stat buf;
|
||||||
if
|
|
||||||
(
|
if (stat(globbuf.gl_pathv[i], &buf) == -1)
|
||||||
!(wfd.dwFileAttributes &
|
continue;
|
||||||
(FILE_ATTRIBUTE_DIRECTORY
|
|
||||||
|FILE_ATTRIBUTE_SYSTEM
|
if (S_ISREG(buf.st_mode) && (access(globbuf.gl_pathv[i], R_OK) == 0)) {
|
||||||
|FILE_ATTRIBUTE_HIDDEN))
|
char *filename = strrchr(globbuf.gl_pathv[i], '/');
|
||||||
// not a directory, hidden or system file
|
if (filename)
|
||||||
)
|
filename++;
|
||||||
{
|
else
|
||||||
char* name=new char[strlen(wfd.cFileName)+1];
|
filename = globbuf.gl_pathv[i];
|
||||||
strcpy(name,wfd.cFileName);
|
|
||||||
char* dotpos=strchr(name,'.');
|
char* name=new char[strlen(filename)+1];
|
||||||
|
strcpy(name,filename);
|
||||||
|
char* dotpos=strrchr(name,'.');
|
||||||
if(dotpos) *dotpos=0;
|
if(dotpos) *dotpos=0;
|
||||||
|
|
||||||
ConfigurationFilenameList.add_entry(name);
|
ConfigurationFilenameList.add_entry(name);
|
||||||
|
|
||||||
BOOL localisedFilename=FALSE;
|
BOOL localisedFilename=FALSE;
|
||||||
|
@ -119,19 +120,10 @@ BOOL BuildLoadMPConfigMenu()
|
||||||
{
|
{
|
||||||
ConfigurationLocalisedFilenameList.add_entry(name);
|
ConfigurationLocalisedFilenameList.add_entry(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}while (::FindNextFile(hFindFile,&wfd));
|
|
||||||
|
|
||||||
|
|
||||||
if (ERROR_NO_MORE_FILES != GetLastError())
|
|
||||||
{
|
|
||||||
printf("Error finding next file\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::FindClose(hFindFile);
|
globfree(&globbuf);
|
||||||
#endif
|
|
||||||
|
|
||||||
//delete the old menu
|
//delete the old menu
|
||||||
if(AvPMenu_Multiplayer_LoadConfig) delete AvPMenu_Multiplayer_LoadConfig;
|
if(AvPMenu_Multiplayer_LoadConfig) delete AvPMenu_Multiplayer_LoadConfig;
|
||||||
|
@ -234,8 +226,6 @@ void LoadMultiplayerConfigurationByIndex(int index)
|
||||||
|
|
||||||
void LoadMultiplayerConfiguration(const char* name)
|
void LoadMultiplayerConfiguration(const char* name)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
FILE* file;
|
FILE* file;
|
||||||
char filename[200];
|
char filename[200];
|
||||||
if(netGameData.skirmishMode)
|
if(netGameData.skirmishMode)
|
||||||
|
@ -246,9 +236,7 @@ void LoadMultiplayerConfiguration(const char* name)
|
||||||
file=fopen(filename,"rb");
|
file=fopen(filename,"rb");
|
||||||
if(!file) return;
|
if(!file) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//set defaults first , in case there are entries not set by this file
|
//set defaults first , in case there are entries not set by this file
|
||||||
SetDefaultMultiplayerConfig();
|
SetDefaultMultiplayerConfig();
|
||||||
|
|
||||||
|
@ -477,18 +465,11 @@ BOOL BuildLoadIPAddressMenu()
|
||||||
|
|
||||||
//do a search for all the addresses in the address directory
|
//do a search for all the addresses in the address directory
|
||||||
|
|
||||||
fprintf(stderr, "STUB: BuildLoadIPAddressMenu()\n");
|
glob_t globbuf;
|
||||||
#if 0
|
|
||||||
const char* load_name=IP_ADDRESS_WILDCARD;
|
const char* load_name=IP_ADDRESS_WILDCARD;
|
||||||
// allow a wildcard search
|
|
||||||
WIN32_FIND_DATA wfd;
|
|
||||||
|
|
||||||
HANDLE hFindFile = ::FindFirstFile(load_name,&wfd);
|
|
||||||
|
|
||||||
if (INVALID_HANDLE_VALUE == hFindFile)
|
if (glob(load_name, 0, NULL, &globbuf))
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
// get any path in the load_name
|
// get any path in the load_name
|
||||||
int nPathLen = 0;
|
int nPathLen = 0;
|
||||||
|
@ -507,30 +488,28 @@ BOOL BuildLoadIPAddressMenu()
|
||||||
if (nLen > nPathLen) nPathLen = nLen;
|
if (nLen > nPathLen) nPathLen = nLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
for (unsigned int i = 0; i < globbuf.gl_pathc; i++) {
|
||||||
{
|
struct stat buf;
|
||||||
if
|
|
||||||
(
|
if (stat(globbuf.gl_pathv[i], &buf) == -1)
|
||||||
!(wfd.dwFileAttributes &
|
continue;
|
||||||
(FILE_ATTRIBUTE_DIRECTORY
|
|
||||||
|FILE_ATTRIBUTE_SYSTEM
|
if (S_ISREG(buf.st_mode) && (access(globbuf.gl_pathv[i], R_OK) == 0)) {
|
||||||
|FILE_ATTRIBUTE_HIDDEN))
|
char *filename = strrchr(globbuf.gl_pathv[i], '/');
|
||||||
// not a directory, hidden or system file
|
if (filename)
|
||||||
)
|
filename++;
|
||||||
{
|
else
|
||||||
char* name=new char[strlen(wfd.cFileName)+1];
|
filename = globbuf.gl_pathv[i];
|
||||||
strcpy(name,wfd.cFileName);
|
|
||||||
|
char* name=new char[strlen(filename)+1];
|
||||||
|
strcpy(name,filename);
|
||||||
char* dotpos=strchr(name,'.');
|
char* dotpos=strchr(name,'.');
|
||||||
if(dotpos) *dotpos=0;
|
if(dotpos) *dotpos=0;
|
||||||
IPAddFilenameList.add_entry(name);
|
IPAddFilenameList.add_entry(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}while (::FindNextFile(hFindFile,&wfd));
|
globfree(&globbuf);
|
||||||
|
|
||||||
|
|
||||||
::FindClose(hFindFile);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//delete the old menu
|
//delete the old menu
|
||||||
if(AvPMenu_Multiplayer_LoadIPAddress) delete [] AvPMenu_Multiplayer_LoadIPAddress;
|
if(AvPMenu_Multiplayer_LoadIPAddress) delete [] AvPMenu_Multiplayer_LoadIPAddress;
|
||||||
|
@ -572,7 +551,6 @@ void SaveIPAddress(const char* name,const char* address)
|
||||||
fwrite(address,1,strlen(address)+1,file);
|
fwrite(address,1,strlen(address)+1,file);
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadIPAddress(const char* name)
|
void LoadIPAddress(const char* name)
|
||||||
|
@ -614,54 +592,49 @@ List<char*> CustomLevelNameList;
|
||||||
void BuildMultiplayerLevelNameArray()
|
void BuildMultiplayerLevelNameArray()
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|
||||||
//only want to do this once
|
//only want to do this once
|
||||||
if(MultiplayerLevelNames) return;
|
if(MultiplayerLevelNames) return;
|
||||||
|
|
||||||
//first do a search for custom level rifs
|
//first do a search for custom level rifs
|
||||||
// allow a wildcard search
|
// allow a wildcard search
|
||||||
|
|
||||||
fprintf(stderr, "STUB: BuildMultiplayerLevelNameArray()\n");
|
const char* load_name="avp_rifs/custom/*.rif";
|
||||||
#if 0
|
|
||||||
WIN32_FIND_DATA wfd;
|
|
||||||
const char* load_name="avp_rifs\\custom\\*.rif";
|
|
||||||
|
|
||||||
HANDLE hFindFile = ::FindFirstFile(load_name,&wfd);
|
|
||||||
|
|
||||||
if (INVALID_HANDLE_VALUE != hFindFile)
|
glob_t globbuf;
|
||||||
{
|
|
||||||
char* custom_string = GetTextString(TEXTSTRING_CUSTOM_LEVEL);
|
if (glob(load_name, 0, NULL, &globbuf) == 0) {
|
||||||
do
|
char* custom_string = GetTextString(TEXTSTRING_CUSTOM_LEVEL);
|
||||||
{
|
int cs_len = strlen(custom_string);
|
||||||
if
|
|
||||||
(
|
for (unsigned int i = 0; i < globbuf.gl_pathc; i++) {
|
||||||
!(wfd.dwFileAttributes &
|
struct stat buf;
|
||||||
(FILE_ATTRIBUTE_DIRECTORY
|
|
||||||
|FILE_ATTRIBUTE_SYSTEM
|
if (stat(globbuf.gl_pathv[i], &buf) == -1)
|
||||||
|FILE_ATTRIBUTE_HIDDEN))
|
continue;
|
||||||
// not a directory, hidden or system file
|
|
||||||
)
|
if (S_ISREG(buf.st_mode) && (access(globbuf.gl_pathv[i], R_OK) == 0)) {
|
||||||
{
|
char *filename = strrchr(globbuf.gl_pathv[i], '/');
|
||||||
strcpy(buffer,wfd.cFileName);
|
if (filename)
|
||||||
char* dotpos=strchr(buffer,'.');
|
filename++;
|
||||||
|
else
|
||||||
|
filename = globbuf.gl_pathv[i];
|
||||||
|
|
||||||
|
char* name=new char[strlen(filename)+cs_len+3+1];
|
||||||
|
|
||||||
|
strcpy(name, filename);
|
||||||
|
char* dotpos=strrchr(name,'.');
|
||||||
if(dotpos) *dotpos=0;
|
if(dotpos) *dotpos=0;
|
||||||
strcat(buffer," (");
|
strcat(name," (");
|
||||||
strcat(buffer,custom_string);
|
strcat(name,custom_string);
|
||||||
strcat(buffer,")");
|
strcat(name,")");
|
||||||
|
|
||||||
char* name=new char[strlen(buffer)+1];
|
CustomLevelNameList.add_entry(name);
|
||||||
strcpy(name,buffer);
|
|
||||||
|
|
||||||
CustomLevelNameList.add_entry(name);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}while (::FindNextFile(hFindFile,&wfd));
|
globfree(&globbuf);
|
||||||
|
|
||||||
|
|
||||||
::FindClose(hFindFile);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
NumCustomLevels = CustomLevelNameList.size();
|
NumCustomLevels = CustomLevelNameList.size();
|
||||||
|
|
||||||
|
|
||||||
|
@ -760,7 +733,6 @@ void BuildMultiplayerLevelNameArray()
|
||||||
}
|
}
|
||||||
elementPtr->b.MaxSliderValue = NumMultiplayerLevels-1;
|
elementPtr->b.MaxSliderValue = NumMultiplayerLevels-1;
|
||||||
elementPtr->d.TextSliderStringPointer = MultiplayerLevelNames;
|
elementPtr->d.TextSliderStringPointer = MultiplayerLevelNames;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -860,7 +832,6 @@ int GetLocalMultiplayerLevelIndex(int index,char* customLevelName,int gameType)
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
12
src/menus.c
12
src/menus.c
|
@ -388,6 +388,18 @@ int LengthOfMenuText(char *textPtr)
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LengthOfSmallMenuText(char *textPtr)
|
||||||
|
{
|
||||||
|
int width = 0;
|
||||||
|
|
||||||
|
while (textPtr && *textPtr) {
|
||||||
|
width += AAFontWidths[(unsigned int) *textPtr];
|
||||||
|
|
||||||
|
textPtr++;
|
||||||
|
}
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
int RenderMenuText(char *textPtr, int sx, int sy, int alpha, enum AVPMENUFORMAT_ID format)
|
int RenderMenuText(char *textPtr, int sx, int sy, int alpha, enum AVPMENUFORMAT_ID format)
|
||||||
{
|
{
|
||||||
int width;
|
int width;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue