Browse Source

Implement Support menu

pull/1040/head
Anders Jenbo 5 years ago
parent
commit
713f74e8d5
  1. 1
      CMakeLists.txt
  2. 3
      DiabloUI/diabloui.h
  3. 4
      Source/mainmenu.cpp
  4. 47
      SourceX/DiabloUI/credits.cpp
  5. 2
      SourceX/DiabloUI/mainmenu.cpp
  6. 29
      SourceX/DiabloUI/support_lines.cpp
  7. 8
      SourceX/DiabloUI/support_lines.h

1
CMakeLists.txt

@ -310,6 +310,7 @@ set(devilutionx_SRCS
SourceX/DiabloUI/button.cpp
SourceX/DiabloUI/credits.cpp
SourceX/DiabloUI/credits_lines.cpp
SourceX/DiabloUI/support_lines.cpp
SourceX/DiabloUI/diabloui.cpp
SourceX/DiabloUI/dialogs.cpp
SourceX/DiabloUI/fonts.cpp

3
DiabloUI/diabloui.h

@ -11,7 +11,8 @@ void UiInitialize();
BOOL UiValidPlayerName(const char *name); /* check */
BOOL UiSelHeroMultDialog(BOOL(*fninfo)(BOOL(*fninfofunc)(_uiheroinfo *)), BOOL(*fncreate)(_uiheroinfo *), BOOL(*fnremove)(_uiheroinfo *), void(*fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, BOOL *hero_is_created, char (* name)[16]);
BOOL UiSelHeroSingDialog(BOOL(*fninfo)(BOOL(*fninfofunc)(_uiheroinfo *)), BOOL(*fncreate)(_uiheroinfo *), BOOL(*fnremove)(_uiheroinfo *), void(*fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, char (* name)[16], int *difficulty);
BOOL UiCreditsDialog(int a1);
BOOL UiCreditsDialog();
BOOL UiSupportDialog();
BOOL UiMainMenuDialog(const char *name, int *pdwResult, void(*fnSound)(const char *file), int attractTimeOut);
BOOL UiProgressDialog(const char *msg, int enable, int(*fnfunc)(), int rate);
const char **UiProfileGetString();

4
Source/mainmenu.cpp

@ -174,10 +174,10 @@ void mainmenu_loop()
mainmenu_play_intro();
break;
case MAINMENU_SHOW_CREDITS:
UiCreditsDialog(16);
UiCreditsDialog();
break;
case MAINMENU_SHOW_SUPPORT:
//UiSupportDialog(16);
UiSupportDialog();
break;
case MAINMENU_EXIT_DIABLO:
done = TRUE;

47
SourceX/DiabloUI/credits.cpp

@ -8,6 +8,7 @@
#include "DiabloUI/diabloui.h"
#include "DiabloUI/credits_lines.h"
#include "DiabloUI/support_lines.h"
#include "DiabloUI/art.h"
#include "DiabloUI/art_draw.h"
#include "DiabloUI/fonts.h"
@ -21,6 +22,9 @@ const int SHADOW_OFFSET_X = 2;
const int SHADOW_OFFSET_Y = 2;
const int LINE_H = 22;
char const *const *text;
std::size_t textLines;
// The maximum number of visible lines is the number of whole lines
// (VIEWPORT.h / LINE_H) rounded up, plus one extra line for when
// a line is leaving the screen while another one is entering.
@ -59,7 +63,7 @@ SDL_Surface *RenderText(const char *text, SDL_Color color)
CachedLine PrepareLine(std::size_t index)
{
const char *contents = CREDITS_LINES[index];
const char *contents = text[index];
while (contents[0] == '\t')
++contents;
@ -105,8 +109,6 @@ class CreditsRenderer {
public:
CreditsRenderer()
{
LoadArt("ui_art\\creditsw.pcx", &ArtBackgroundWidescreen);
LoadBackgroundArt("ui_art\\credits.pcx");
LoadTtfFont();
ticks_begin_ = SDL_GetTicks();
prev_offset_y_ = 0;
@ -153,10 +155,10 @@ void CreditsRenderer::Render()
return;
const std::size_t lines_begin = std::max(offset_y / LINE_H, 0);
const std::size_t lines_end = std::min(lines_begin + MAX_VISIBLE_LINES, CREDITS_LINES_SIZE);
const std::size_t lines_end = std::min(lines_begin + MAX_VISIBLE_LINES, textLines);
if (lines_begin >= lines_end) {
if (lines_end == CREDITS_LINES_SIZE)
if (lines_end == textLines)
finished_ = true;
return;
}
@ -185,7 +187,7 @@ void CreditsRenderer::Render()
Sint16 dest_x = PANEL_LEFT + VIEWPORT.x + 31;
int j = 0;
while (CREDITS_LINES[line.m_index][j++] == '\t')
while (text[line.m_index][j++] == '\t')
dest_x += 40;
SDL_Rect dst_rect = { dest_x, dest_y, 0, 0 };
@ -198,9 +200,7 @@ void CreditsRenderer::Render()
SDL_SetClipRect(GetOutputSurface(), NULL);
}
} // namespace
BOOL UiCreditsDialog(int a1)
BOOL TextDialog()
{
CreditsRenderer credits_renderer;
bool endMenu = false;
@ -232,4 +232,33 @@ BOOL UiCreditsDialog(int a1)
return true;
}
} // namespace
BOOL UiCreditsDialog()
{
text = CREDITS_LINES;
textLines = CREDITS_LINES_SIZE;
LoadArt("ui_art\\creditsw.pcx", &ArtBackgroundWidescreen);
LoadBackgroundArt("ui_art\\credits.pcx");
return TextDialog();
}
BOOL UiSupportDialog()
{
text = SUPPORT_LINES;
textLines = SUPPORT_LINES_SIZE;
if (gbIsHellfire) {
LoadArt("ui_art\\supportw.pcx", &ArtBackgroundWidescreen);
LoadBackgroundArt("ui_art\\support.pcx");
} else {
LoadArt("ui_art\\creditsw.pcx", &ArtBackgroundWidescreen);
LoadBackgroundArt("ui_art\\credits.pcx");
}
return TextDialog();
}
} // namespace dvl

2
SourceX/DiabloUI/mainmenu.cpp

@ -39,8 +39,8 @@ void mainmenu_Load(const char *name, void (*fnSound)(const char *file))
vecMenuItems.push_back(new UiListItem("Single Player", MAINMENU_SINGLE_PLAYER));
vecMenuItems.push_back(new UiListItem("Multi Player", MAINMENU_MULTIPLAYER));
vecMenuItems.push_back(new UiListItem("Replay Intro", MAINMENU_REPLAY_INTRO));
vecMenuItems.push_back(new UiListItem("Support", MAINMENU_SHOW_SUPPORT));
if (gbIsHellfire) {
vecMenuItems.push_back(new UiListItem("Support", MAINMENU_SHOW_SUPPORT));
vecMenuItems.push_back(new UiListItem("Credits", MAINMENU_SHOW_CREDITS));
vecMenuItems.push_back(new UiListItem("Exit Hellfire", MAINMENU_EXIT_DIABLO));
} else {

29
SourceX/DiabloUI/support_lines.cpp

@ -0,0 +1,29 @@
#include "DiabloUI/support_lines.h"
namespace dvl {
const char *const SUPPORT_LINES[] = {
"",
"GOG.com maintains a web site at https://www.gog.com/forum/diablo",
"Follow the links to visit the discussion boards associated with Diablo.",
"and the Hellfire expansion.",
"",
"DevilutionX is maintained by Diasurgical, issues and bugs can be reported",
"at this address: https://github.com/diasurgical/devilutionX",
"To help us better serve you, please be sure to include the version number,",
"operating system, and the nature of the problem.",
"",
"",
"Disclaimer:",
" DevilutionX is not supported or maintained by Blizzard Entertainment,",
" nor GOG.com. Neither Blizzard Entertainment or GOG.com has not tested or",
" certified the quality or compatibility of DevilutionX. All inquiries",
" regarding DevilutionX should be directed to Diasurgical, not to Blizzard",
" Entertainment or GOG.com.",
"",
"",
};
const std::size_t SUPPORT_LINES_SIZE = sizeof(SUPPORT_LINES) / sizeof(SUPPORT_LINES[0]);
} // namespace dvl

8
SourceX/DiabloUI/support_lines.h

@ -0,0 +1,8 @@
#include <cstddef>
namespace dvl {
extern const char *const SUPPORT_LINES[];
extern const std::size_t SUPPORT_LINES_SIZE;
} // namespace dvl
Loading…
Cancel
Save