raze/source/duke3d/src/menus.cpp

226 lines
8 KiB
C++
Raw Normal View History

//-------------------------------------------------------------------------
/*
Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "cheats.h"
#include "compat.h"
#include "demo.h"
#include "duke3d.h"
#include "menus.h"
#include "osdcmds.h"
#include "savegame.h"
#include "superfasthash.h"
#include "gamecvars.h"
#include "gamecontrol.h"
#include "c_bind.h"
#include "../../glbackend/glbackend.h"
bool ShowOptionMenu();
namespace ImGui
{
void ShowDemoWindow(bool*);
}
BEGIN_DUKE_NS
#if 0
void Menu_Init(void)
{
int32_t i, j, k;
if (FURY)
// prepare shareware
if (VOLUMEONE)
{
// blue out episodes beyond the first
for (i = 1; i < g_volumeCnt; ++i)
{
if (MEL_EPISODE[i])
{
ME_EPISODE[i].entry = &MEO_EPISODE_SHAREWARE;
ME_EPISODE[i].flags |= MEF_LookDisabled;
}
}
M_EPISODE.numEntries = g_volumeCnt; // remove User Map (and spacer)
MEOS_NETOPTIONS_EPISODE.numOptions = 1;
MenuEntry_DisableOnCondition(&ME_NETOPTIONS_EPISODE, 1);
}
}
static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin)
{
int32_t i, j, l = 0;
switch (cm)
{
case MENU_CREDITS4: // JBF 20031220
{
#define MENU_YOFFSET 40
#define MENU_INCREMENT(x) (oy += ((x) << 16)) // maybe this should have been MENU_EXCREMENT instead
int32_t oy = origin.y;
mgametextcenter(origin.x, MENU_INCREMENT(MENU_YOFFSET), "Developers");
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Richard \"TerminX\" Gobeille", 8);
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(7), "Evan \"Hendricks266\" Ramos", 8);
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(7), "Alex \"pogokeen\" Dawson", 8);
mgametextcenter(origin.x, MENU_INCREMENT(11), "Retired developers");
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Pierre-Loup \"Plagman\" Griffais", 8);
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(7), "Philipp \"Helixhorned\" Kutin", 8);
Massive menu input control revamp/cleanup/factor. (added: input.[ch]) New Wii control defaults for the Wii Remote + Nunchuk and the Classic Controller. This includes new code added just so that the Home key brings up the menu in-game, reducing the need for a USB keyboard. On the technical side, raw joystick access (comparable to what is available for keyboard and mouse) is now present in jmact, on the game side. (added: joystick.[ch]) Using this new raw joystick access, I replaced tueidj's hack to map A and B to LMB/RMB and D-Pad Up/Down to the scrollwheel. I made the menus more friendly to mouse and joystick browsing by adding and unifying checks and clears for various buttons and gamefuncs. In fact, the majority of the time spent on this commit was tracking down problems that appeared with the factoring and trying to understand the menu system and the way input checks are precariously executed. In addition, "Press any key or button to continue" now truly means what it says. As a result of incorporating proper raw access into control.c instead of it directly accessing the implementaiton, the program *may* no longer be affected by joystick input when it is out of focus. This follows the pattern set by the mouse, and I think this is a positive change. A small bonus: In the classic/old keyboard preset, the key for Show_Console has been changed from '`' to 'C' because '`' is taken by Quick_Kick. git-svn-id: https://svn.eduke32.com/eduke32@2728 1a8010ca-5511-0410-912e-c29ae57300e0
2012-06-03 16:11:22 +00:00
mgametextcenter(origin.x, MENU_INCREMENT(11), "Special thanks to");
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Jonathon \"JonoF\" Fowler", 8);
Massive menu input control revamp/cleanup/factor. (added: input.[ch]) New Wii control defaults for the Wii Remote + Nunchuk and the Classic Controller. This includes new code added just so that the Home key brings up the menu in-game, reducing the need for a USB keyboard. On the technical side, raw joystick access (comparable to what is available for keyboard and mouse) is now present in jmact, on the game side. (added: joystick.[ch]) Using this new raw joystick access, I replaced tueidj's hack to map A and B to LMB/RMB and D-Pad Up/Down to the scrollwheel. I made the menus more friendly to mouse and joystick browsing by adding and unifying checks and clears for various buttons and gamefuncs. In fact, the majority of the time spent on this commit was tracking down problems that appeared with the factoring and trying to understand the menu system and the way input checks are precariously executed. In addition, "Press any key or button to continue" now truly means what it says. As a result of incorporating proper raw access into control.c instead of it directly accessing the implementaiton, the program *may* no longer be affected by joystick input when it is out of focus. This follows the pattern set by the mouse, and I think this is a positive change. A small bonus: In the classic/old keyboard preset, the key for Show_Console has been changed from '`' to 'C' because '`' is taken by Quick_Kick. git-svn-id: https://svn.eduke32.com/eduke32@2728 1a8010ca-5511-0410-912e-c29ae57300e0
2012-06-03 16:11:22 +00:00
mgametextcenter(origin.x, MENU_INCREMENT(11), "Uses BUILD Engine technology by");
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Ken \"Awesoken\" Silverman", 8);
#undef MENU_INCREMENT
#undef MENU_YOFFSET
}
break;
case MENU_CREDITS5:
l = 7;
mgametextcenter(origin.x, origin.y + ((38-l)<<16), "License and Other Contributors");
{
static const char *header[] =
{
"This program is distributed under the terms of the",
"GNU General Public License version 2 as published by the",
"Free Software Foundation. See gpl-2.0.txt for details.",
"BUILD engine technology available under license. See buildlic.txt.",
nullptr,
"The EDuke32 team thanks the following people for their contributions:",
nullptr,
};
static const char *body[] =
{
"Alexey Skrybykin", // Nuke.YKT - Polymost fixes
"Bioman", // GTK work, APT repository and package upkeep
"Brandon Bergren", // "Bdragon" - tiles.cfg
"Charlie Honig", // "CONAN" - showview command
"Dan Gaskill", // "DeeperThought" - testing
"David Koenig", // "Bargle" - Merged a couple of things from duke3d_w32
"Ed Coolidge", // Mapster32 improvements
"Emile Belanger", // original Android work
"Fox", // various patches
"Hunter_rus", // tons of stuff
"James Bentler", // Mapster32 improvements
"Jasper Foreman", // netcode contributions
"Javier Martinez", // "Malone3D" - EDuke 2.1.1 components
"Jeff Hart", // website graphics
"Jonathan Strander", // "Mblackwell" - testing and feature speccing
"Jordon Moss", // "Striker" - various patches, OldMP work
"Jose del Castillo", // "Renegado" - EDuke 2.1.1 components
"Lachlan McDonald", // official EDuke32 icon
"LSDNinja", // OS X help and testing
"Marcus Herbert", // "rhoenie" - OS X compatibility work
"Matthew Palmer", // "Usurper" - testing and eduke32.com domain
"Matt Saettler", // original DOS EDuke/WW2GI enhancements
"NY00123", // Linux / SDL usability patches
"Ozkan Sezer", // SDL/GTK version checking improvements
"Peter Green", // "Plugwash" - dynamic remapping, custom gametypes
"Peter Veenstra", // "Qbix" - port to 64-bit
"Robin Green", // CON array support
"Ryan Gordon", // "icculus" - icculus.org Duke3D port sound code
"Stephen Anthony", // early 64-bit porting work
"tueidj", // Wii port
};
EDUKE32_STATIC_ASSERT(ARRAY_SIZE(body) % 3 == 0);
static const char *footer[] =
{
nullptr,
"Visit eduke32.com for news and updates",
};
static constexpr int header_numlines = ARRAY_SIZE(header);
static constexpr int body_numlines = ARRAY_SIZE(body);
static constexpr int footer_numlines = ARRAY_SIZE(footer);
static constexpr int CCOLUMNS = 3;
static constexpr int CCOLXBUF = 20;
int c;
i = 0;
for (c = 0; c < header_numlines; c++)
if (header[c])
creditsminitext(origin.x + (160<<16), origin.y + ((17+10+10+8+4+(c*7)-l)<<16), header[c], 8);
i += c;
for (c = 0; c < body_numlines; c++)
if (body[c])
creditsminitext(origin.x + ((CCOLXBUF+((320-CCOLXBUF*2)/(CCOLUMNS*2)) +((320-CCOLXBUF*2)/CCOLUMNS)*(c/(body_numlines/CCOLUMNS)))<<16), origin.y + ((17+10+10+8+4+((c%(body_numlines/CCOLUMNS))*7)+(i*7)-l)<<16), body[c], 8);
i += c/CCOLUMNS;
for (c = 0; c < footer_numlines; c++)
if (footer[c])
creditsminitext(origin.x + (160<<16), origin.y + ((17+10+10+8+4+(c*7)+(i*7)-l)<<16), footer[c], 8);
}
break;
default:
break;
}
}
Massive menu input control revamp/cleanup/factor. (added: input.[ch]) New Wii control defaults for the Wii Remote + Nunchuk and the Classic Controller. This includes new code added just so that the Home key brings up the menu in-game, reducing the need for a USB keyboard. On the technical side, raw joystick access (comparable to what is available for keyboard and mouse) is now present in jmact, on the game side. (added: joystick.[ch]) Using this new raw joystick access, I replaced tueidj's hack to map A and B to LMB/RMB and D-Pad Up/Down to the scrollwheel. I made the menus more friendly to mouse and joystick browsing by adding and unifying checks and clears for various buttons and gamefuncs. In fact, the majority of the time spent on this commit was tracking down problems that appeared with the factoring and trying to understand the menu system and the way input checks are precariously executed. In addition, "Press any key or button to continue" now truly means what it says. As a result of incorporating proper raw access into control.c instead of it directly accessing the implementaiton, the program *may* no longer be affected by joystick input when it is out of focus. This follows the pattern set by the mouse, and I think this is a positive change. A small bonus: In the classic/old keyboard preset, the key for Show_Console has been changed from '`' to 'C' because '`' is taken by Quick_Kick. git-svn-id: https://svn.eduke32.com/eduke32@2728 1a8010ca-5511-0410-912e-c29ae57300e0
2012-06-03 16:11:22 +00:00
/*
Functions where a "newValue" or similar is passed are run *before* the linked variable is actually changed.
That way you can compare the new and old values and potentially block the change.
*/
static void Menu_EntryLinkActivate(MenuEntry_t *entry)
{
else if (entry == &ME_NETHOST_LAUNCH)
{
// master does whatever it wants
if (g_netServer)
{
Net_FillNewGame(&pendingnewgame, 1);
Net_StartNewGame();
Net_SendNewGame(1, NULL);
}
else if (voting == -1)
{
Net_SendMapVoteInitiate();
Menu_Change(MENU_NETWAITVOTES);
}
}
}
#endif
END_DUKE_NS