mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 12:35:52 -04:00
Fix error message shown when accepted.txt is in plugins folder
This commit is contained in:
parent
48fce2f25f
commit
e4406a60a9
@ -373,12 +373,15 @@ static void Game_LoadOptions(void) {
|
||||
}
|
||||
|
||||
static void Game_LoadPlugin(const String* filename, void* obj) {
|
||||
const static String txt = String_FromConst(".txt");
|
||||
void* lib;
|
||||
void* verSymbol; /* EXPORT int Plugin_ApiVersion = GAME_API_VER; */
|
||||
void* compSymbol; /* EXPORT struct IGameComponent Plugin_Component = { (whatever) } */
|
||||
int ver;
|
||||
ReturnCode res;
|
||||
|
||||
/* ignore classicalsharp's accepted.txt */
|
||||
if (String_CaselessEnds(filename, &txt)) return;
|
||||
res = Platform_LoadLibrary(filename, &lib);
|
||||
if (res) { Chat_LogError2(res, "loading plugin", filename); return; }
|
||||
|
||||
|
@ -1111,7 +1111,7 @@ struct LScreen* ResourcesScreen_MakeInstance(void) {
|
||||
*#########################################################################################################################*/
|
||||
static struct ServersScreen {
|
||||
LScreen_Layout
|
||||
struct LInput IptName, IptHash;
|
||||
struct LInput IptSearch, IptHash;
|
||||
struct LButton BtnBack, BtnConnect, BtnRefresh;
|
||||
struct LTable Table;
|
||||
struct LWidget* _widgets[6];
|
||||
@ -1133,6 +1133,21 @@ static void ServersScreen_Refresh(void* w, int x, int y) {
|
||||
LWidget_Redraw(btn);
|
||||
}
|
||||
|
||||
static void ServersScreen_HashFilter(String* str) {
|
||||
int lastIndex;
|
||||
/* Server url look like http://www.classicube.net/server/play/aaaaa/ */
|
||||
/* Trim it to only be the aaaaa */
|
||||
|
||||
if (str->buffer[str->length - 1] == '/') {
|
||||
String_DeleteAt(str, str->length - 1);
|
||||
}
|
||||
|
||||
/* Trim the URL parts before the hash */
|
||||
lastIndex = String_LastIndexOf(str, '/');
|
||||
if (lastIndex == -1) return;
|
||||
*str = String_UNSAFE_SubstringAt(str, lastIndex + 1);
|
||||
}
|
||||
|
||||
static void ServersScreen_SearchChanged(struct LInput* w) {
|
||||
struct ServersScreen* s = &ServersScreen_Instance;
|
||||
LTable_Filter(&s->Table, &w->Text);
|
||||
@ -1143,8 +1158,8 @@ static void ServersScreen_InitWidgets(struct LScreen* s_) {
|
||||
struct ServersScreen* s = (struct ServersScreen*)s_;
|
||||
s->Widgets = s->_widgets;
|
||||
|
||||
LScreen_Input(s_, &s->IptName, 370, false, "&gSearch servers..");
|
||||
LScreen_Input(s_, &s->IptHash, 475, false, "&gclassicube.net/server/play/...");
|
||||
LScreen_Input(s_, &s->IptSearch, 370, false, "&gSearch servers..");
|
||||
LScreen_Input(s_, &s->IptHash, 475, false, "&gclassicube.net/server/play/...");
|
||||
|
||||
LScreen_Button(s_, &s->BtnBack, 110, 30, "Back");
|
||||
LScreen_Button(s_, &s->BtnConnect, 130, 30, "Connect");
|
||||
@ -1154,7 +1169,8 @@ static void ServersScreen_InitWidgets(struct LScreen* s_) {
|
||||
s->BtnConnect.OnClick = ServersScreen_Connect;
|
||||
s->BtnRefresh.OnClick = ServersScreen_Refresh;
|
||||
|
||||
s->IptName.TextChanged = ServersScreen_SearchChanged;
|
||||
s->IptSearch.TextChanged = ServersScreen_SearchChanged;
|
||||
s->IptHash.ClipboardFilter = ServersScreen_HashFilter;
|
||||
|
||||
LTable_Init(&s->Table, &Launcher_TextFont, &s->RowFont);
|
||||
s->Widgets[s->NumWidgets++] = (struct LWidget*)&s->Table;
|
||||
@ -1166,11 +1182,12 @@ static void ServersScreen_Init(struct LScreen* s_) {
|
||||
|
||||
if (!s->NumWidgets) ServersScreen_InitWidgets(s_);
|
||||
s->Table.RowFont = s->RowFont;
|
||||
LTable_Reset(&s->Table);
|
||||
|
||||
s->IptHash.Text.length = 0;
|
||||
s->IptName.Text.length = 0;
|
||||
LTable_Filter(&s->Table, &s->IptHash.Text);
|
||||
LScreen_SelectWidget(s_, (struct LWidget*)&s->IptName, false);
|
||||
/* unlike other menus, don't want these to persist */
|
||||
s->IptHash.Text.length = 0;
|
||||
s->IptSearch.Text.length = 0;
|
||||
LScreen_SelectWidget(s_, (struct LWidget*)&s->IptSearch, false);
|
||||
}
|
||||
|
||||
static void ServersScreen_Free(struct LScreen* s_) {
|
||||
@ -1180,8 +1197,8 @@ static void ServersScreen_Free(struct LScreen* s_) {
|
||||
|
||||
static void ServersScreen_Reposition(struct LScreen* s_) {
|
||||
struct ServersScreen* s = (struct ServersScreen*)s_;
|
||||
LWidget_SetLocation(&s->IptName, ANCHOR_MIN, ANCHOR_MIN, 10, 10);
|
||||
LWidget_SetLocation(&s->IptHash, ANCHOR_MIN, ANCHOR_MAX, 10, 10);
|
||||
LWidget_SetLocation(&s->IptSearch, ANCHOR_MIN, ANCHOR_MIN, 10, 10);
|
||||
LWidget_SetLocation(&s->IptHash, ANCHOR_MIN, ANCHOR_MAX, 10, 10);
|
||||
|
||||
LWidget_SetLocation(&s->BtnBack, ANCHOR_MAX, ANCHOR_MIN, 10, 10);
|
||||
LWidget_SetLocation(&s->BtnConnect, ANCHOR_MAX, ANCHOR_MAX, 10, 10);
|
||||
|
@ -1047,7 +1047,13 @@ void ScrollbarClick(int mouseY) {
|
||||
}
|
||||
*/
|
||||
|
||||
void LTable_StopDragging(struct LTable* table) {
|
||||
static int LTable_DefaultSort(struct ServerInfo* a, struct ServerInfo* b) {
|
||||
/* highest players, then highest uptime*/
|
||||
if (a->Players != b->Players) return b->Players - a->Players;
|
||||
return b->Uptime - a->Uptime;
|
||||
}
|
||||
|
||||
static void LTable_StopDragging(struct LTable* table) {
|
||||
table->DraggingColumn = -1;
|
||||
table->DraggingScrollbar = false;
|
||||
table->MouseOffset = 0;
|
||||
@ -1083,9 +1089,13 @@ void LTable_Init(struct LTable* w, const FontDesc* hdrFont, const FontDesc* rowF
|
||||
|
||||
w->HdrFont = *hdrFont;
|
||||
w->RowFont = *rowFont;
|
||||
}
|
||||
|
||||
void LTable_Reset(struct LTable* w) {
|
||||
LTable_StopDragging(w);
|
||||
LTable_Reposition(w);
|
||||
w->Sorter = LTable_DefaultSort;
|
||||
LTable_Filter(w, &String_Empty);
|
||||
}
|
||||
|
||||
void LTable_Filter(struct LTable* w, const String* filter) {
|
||||
|
@ -66,7 +66,7 @@ struct LInput {
|
||||
/* Whether all characters should be rendered as *. */
|
||||
bool Password;
|
||||
/* Filter applied to text received from the clipboard. Can be NULL. */
|
||||
void (*ClipboardFilter)(String* text);
|
||||
void (*ClipboardFilter)(String* str);
|
||||
/* Callback invoked when the text is changed. Can be NULL. */
|
||||
void (*TextChanged)(struct LInput* w);
|
||||
/* Filter that only lets certain characters be entered. Can be NULL. */
|
||||
@ -111,7 +111,9 @@ struct LSlider {
|
||||
};
|
||||
CC_NOINLINE void LSlider_Init(struct LSlider* w, int width, int height);
|
||||
|
||||
struct ServerInfo;
|
||||
/* Returns sort order of two rows/server entries. */
|
||||
typedef int (*LTableSorter)(struct ServerInfo* a, struct serverInfo* b);
|
||||
|
||||
struct LTableColumn {
|
||||
/* Name of this column. */
|
||||
const char* Name;
|
||||
@ -120,10 +122,11 @@ struct LTableColumn {
|
||||
/* Gets the value of this column for the given row. */
|
||||
void (*GetValue)(struct ServerInfo* row, String* str);
|
||||
/* Sorts two rows based on value of this column in both rows. */
|
||||
int (*SortRows)(struct ServerInfo* a, struct ServerInfo* b);
|
||||
LTableSorter SortRows;
|
||||
/* Whether to invert the order of row sorting. */
|
||||
bool InvertSort;
|
||||
};
|
||||
|
||||
/* Represents a table of server entries. */
|
||||
struct LTable {
|
||||
LWidget_Layout
|
||||
@ -141,6 +144,8 @@ struct LTable {
|
||||
int VisibleRows;
|
||||
/* Total number of rows in the table (after filter is applied). */
|
||||
int RowsCount;
|
||||
/* Comparison function used to sort rows. */
|
||||
LTableSorter Sorter;
|
||||
|
||||
/* Index of column currently being dragged. */
|
||||
int DraggingColumn;
|
||||
@ -148,8 +153,12 @@ struct LTable {
|
||||
bool DraggingScrollbar;
|
||||
int MouseOffset;
|
||||
};
|
||||
/* Initialises a table. */
|
||||
/* NOTE: Must also call LTable_Reset to make a table actually useful. */
|
||||
void LTable_Init(struct LTable* table, const FontDesc* hdrFont, const FontDesc* rowFont);
|
||||
CC_NOINLINE void LTable_StopDragging(struct LTable* table);
|
||||
/* Resets state of a table (reset sorter, filter, etc) */
|
||||
void LTable_Reset(struct LTable* table);
|
||||
/* Adjusts Y position of rows and number of visible rows. */
|
||||
void LTable_Reposition(struct LTable* table);
|
||||
/* Filters rows to only show those containing 'filter' in the name. */
|
||||
void LTable_Filter(struct LTable* table, const String* filter);
|
||||
|
Loading…
x
Reference in New Issue
Block a user