Menu: Added readme menu page, allow inserting of text that'll get wrapped

automatically. Mods can have their own readme.txt files parsed too now.
This commit is contained in:
Marco Cawthorne 2020-07-09 20:00:16 +02:00
parent c0f97524ce
commit 7eee535e39
8 changed files with 200 additions and 7 deletions

View File

@ -0,0 +1,52 @@
Nuclide
Alpha Version
Readme File
6/09/2020
*****************************************************************
About This Document:
This document contains general help information regarding Nuclide. Thank you for downloading this project, we hope you enjoy tinkering or playing with this software. Keep it free, keep it open.
*****************************************************************
I. LICENSE
II. OWNERSHIP
III. PRIVACY POLICY
IV. REPORTING BUGS/ISSUES
V. SPECIAL THANKS
I. LICENSE
Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
II. OWNERSHIP
This software is copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>.
III. PRIVACY POLICY
The software may connect to the Internet to enable features such as a real-time chat room application, or to get dynamic listings of open multiplayer games from a master-server. The software may also broadcast the users' public internet address and game-server metadata to said master-server to enable other users the ability to establish a direct connection to you, the user.
If you're not in any way approving of these features, do not use the Multiplayer option for either 'Internet games' or 'Chat rooms', or stop using the software entirely.
IV. REPORTING BUGS/ISSUES
For hardware related issues, crashes to desktop and network protocol/connection issues, visit the FTEQW-Engine channel on irc.quakenet.org #fte to get real-time help and information.
For problems related to the game-logic that e.g. enable a crash to the engine's console, visit the corresponding channel for the game you'd like to receive support for at irc.frag-net.com.
V. SPECIAL THANKS
Spike
Xylemon
twhl.info
theuaredead
Little Caesars
all the other UNIX hackers that dl my wares

View File

@ -141,7 +141,6 @@ m_shutdown(void)
memfree(g_sprays);
memfree(g_models);
memfree(g_maps);
memfree(games);
}

View File

@ -51,7 +51,7 @@ void
cr_print(string buffer)
{
print(sprintf("%s\n", buffer));
cr_lbHistory.Insert(buffer);
cr_lbHistory.InsertWrapped(buffer);
}
/* tempstrings and fwrite == not a good idea. we need to manually copy all

View File

@ -28,7 +28,6 @@ CFrame create_frMaps;
CListBox create_lbMaps;
CScrollbar create_sbMaps;
string *g_maps;
int g_mapcount;
void
@ -138,10 +137,10 @@ menu_creategame_init(void)
searchhandle mapsearch = search_begin("maps/*.bsp", TRUE, TRUE);
g_mapcount = search_getsize(mapsearch);
g_maps = memalloc(sizeof(string) * g_mapcount);
for (int i = 0; i < g_mapcount; i++) {
g_maps[i] = substring(search_getfilename(mapsearch, i), 5, -1);
create_lbMaps.AddEntry(g_maps[i]);
string tmp;
tmp = substring(search_getfilename(mapsearch, i), 5, -1);
create_lbMaps.AddEntry(tmp);
}
create_sbMaps.SetMax(g_mapcount);

View File

@ -133,7 +133,7 @@ btn_customgame_start(void)
g_menupage = PAGE_CUSTOMGAME;
}
localsound("../media/launch_upmenu1.wav");
header.SetStartEndPos(70,320,45,45);
header.SetStartEndPos(70,348,45,45);
header.SetStartEndSize(156,26,460,80);
header.m_lerp = 0.0f;
header.m_visible = TRUE;
@ -141,6 +141,21 @@ btn_customgame_start(void)
header.SetExecute(btn_customgame_end);
}
void
btn_readme_start(void)
{
static void btn_readme_end(void) {
g_menupage = PAGE_VIEWREADME;
}
localsound("../media/launch_upmenu1.wav");
header.SetStartEndPos(70,376,45,45);
header.SetStartEndSize(156,26,460,80);
header.m_lerp = 0.0f;
header.m_visible = TRUE;
header.SetHeader(HEAD_README);
header.SetExecute(btn_readme_end);
}
void
btn_quit(void)
{
@ -218,6 +233,7 @@ menu_main_init(void)
main_btnReadme = spawn(CMainButton);
main_btnReadme.SetImage(BTN_README);
main_btnReadme.SetExecute(btn_readme_start);
main_btnReadme.SetPos(70,376);
Widget_Add(fn_main, main_btnReadme);

View File

@ -14,17 +14,82 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
CWidget vr_readme;
CMainButton vr_btnDone;
CFrame vr_frReadme;
CListBox vr_lbReadme;
CScrollbar vr_sbReadme;
void
vr_btndone_start(void)
{
static void vr_btndone_end(void) {
g_menupage = PAGE_MAIN;
}
localsound("../media/launch_dnmenu1.wav");
header.SetStartEndPos(45,45,70,376);
header.SetStartEndSize(460,80,156,26);
header.m_lerp = 0.0f;
header.m_visible = TRUE;
header.SetHeader(HEAD_README);
header.SetExecute(vr_btndone_end);
}
void
vr_sbreadme_changed(int val)
{
vr_lbReadme.SetScroll(val);
}
void
menu_viewreadme_init(void)
{
vr_readme = spawn(CWidget);
vr_btnDone = spawn(CMainButton);
vr_btnDone.SetImage(BTN_DONE);
vr_btnDone.SetExecute(vr_btndone_start);
vr_btnDone.SetPos(50,140);
Widget_Add(vr_readme, vr_btnDone);
vr_frReadme = spawn(CFrame);
vr_frReadme.SetPos(225,140);
vr_frReadme.SetSize(364,290);
Widget_Add(vr_readme, vr_frReadme);
vr_lbReadme = spawn(CListBox);
vr_lbReadme.SetPos(229,143);
vr_lbReadme.SetSize(342,284);
Widget_Add(vr_readme, vr_lbReadme);
vr_sbReadme = spawn(CScrollbar);
vr_sbReadme.SetPos(571,143);
vr_sbReadme.SetHeight(284);
vr_sbReadme.SetCallback(vr_sbreadme_changed);
Widget_Add(vr_readme, vr_sbReadme);
filestream rdme;
string lstline;
rdme = fopen("readme.txt", FILE_READ);
if (rdme >= 0) {
while((lstline = fgets(rdme))) {
vr_lbReadme.AddWrapped(lstline);
}
fclose(rdme);
}
vr_sbReadme.SetMax(vr_lbReadme.GetCount());
}
void
menu_viewreadme_draw(void)
{
Widget_Draw(vr_readme);
drawpic([g_menuofs[0]+45,g_menuofs[1]+45], g_bmp[HEAD_README],[460,80], [1,1,1], 1.0f, 1);
}
void
menu_viewreadme_input(float evtype, float scanx, float chary, float devid)
{
Widget_Input(vr_readme, evtype, scanx, chary, devid);
}

View File

@ -30,6 +30,7 @@ class CListBox:CWidget
virtual void(float, float, float, float) Input;
virtual void(string) AddEntry;
virtual void(string) AddWrapped;
virtual void(int) DelEntry;
virtual void(void) Clear;
virtual void(int, int) SetSize;
@ -108,6 +109,36 @@ CListBox::AddEntry(string m)
}
}
void
CListBox::AddWrapped(string m)
{
int len;
int argc;
string tmp;
string new;
drawfont = font_label;
argc = tokenizebyseparator(m, " ");
tmp = new = "";
for (int i = 0; i < argc; i++) {
tmp = sprintf("%s%s ", new, argv(i));
len = stringwidth(tmp, TRUE, [12, 12]);
if (len >= m_size[0]) {
AddEntry(new);
new = "";
} else {
new = tmp;
}
}
AddEntry(new);
}
void
CListBox::DelEntry(int i)
{

View File

@ -27,6 +27,7 @@ class CTextBuffer:CWidget
virtual void(float, float, float, float) Input;
virtual void(string) Insert;
virtual void(string) InsertWrapped;
virtual void(void) Clear;
virtual void(int, int) SetSize;
};
@ -75,6 +76,36 @@ CTextBuffer::Insert(string m)
}
}
void
CTextBuffer::InsertWrapped(string m)
{
int len;
int argc;
string tmp;
string new;
drawfont = font_label;
argc = tokenizebyseparator(m, " ");
tmp = new = "";
for (int i = 0; i < argc; i++) {
tmp = sprintf("%s%s ", new, argv(i));
len = stringwidth(tmp, TRUE, [12, 12]);
if (len >= m_size[0]) {
Insert(new);
new = "";
} else {
new = tmp;
}
}
Insert(new);
}
void
CTextBuffer::Clear(void)
{