Skip to content

Commit

Permalink
Merge pull request diasurgical#10 from wkdgmr/refactor_devx_15
Browse files Browse the repository at this point in the history
Refactor DevX 1.5 Release
  • Loading branch information
wkdgmr authored Jun 18, 2023
2 parents 8aa374b + b3d37b8 commit 1b226bb
Show file tree
Hide file tree
Showing 59 changed files with 881 additions and 181 deletions.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ body:
attributes:
label: DevilutionX version
options:
- 1.4.1 (latest release)
- 1.5.0 (latest release)
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.1
Expand Down
2 changes: 2 additions & 0 deletions CMake/Assets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ set(devilutionx_assets
levels/l2data/bonechat.dun
levels/towndata/automap.dun
levels/towndata/automap.amp
nlevels/cutl5w.clx
nlevels/cutl6w.clx
nlevels/l5data/cornerstone.dun
nlevels/l5data/uberroom.dun
ui_art/diablo.pal
Expand Down
3 changes: 3 additions & 0 deletions CMake/platforms/vita.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ set(NOEXIT ON)
list(APPEND DEVILUTIONX_PLATFORM_SUBDIRECTORIES platform/vita)
list(APPEND DEVILUTIONX_PLATFORM_LINK_LIBRARIES libdevilutionx_vita)
list(APPEND DEVILUTIONX_PLATFORM_COMPILE_DEFINITIONS VITA)

# The Vita build needs the information
set(DEVILUTIONX_DISABLE_STRIP ON)
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ if(NOT VERSION_NUM)
endif()

if(NOT VERSION_SUFFIX)
# For versions with a suffix, e.g. "1.5.0-dev", include
# the build type and the git hash.
set(VERSION_SUFFIX "-$<CONFIG>")
if(VERSION_PREFIX MATCHES "-")
if(NOT GIT_COMMIT_HASH)
Expand All @@ -65,13 +67,17 @@ if(NOT VERSION_SUFFIX)
if(GIT_COMMIT_HASH)
set(VERSION_SUFFIX "${VERSION_SUFFIX}-${GIT_COMMIT_HASH}")
endif()
else()
# For versions without a suffix, e.g. "1.5.0" rather than "1.5.0-dev",
# only include the build type if it is a debug build.
set(VERSION_SUFFIX "$<$<CONFIG:Debug>:$<CONFIG>>")
endif()
endif()

project(wkdmod
VERSION ${VERSION_NUM}
LANGUAGES C CXX)
set(PROJECT_VERSION_WITH_SUFFIX "${VERSION_PREFIX}$<$<NOT:$<CONFIG:Release>>:${VERSION_SUFFIX}>")
set(PROJECT_VERSION_WITH_SUFFIX "${VERSION_PREFIX}${VERSION_SUFFIX}")

# Platform definitions can override options and we want `cmake_dependent_option` to see the effects.
# Note that a few options are still defined before this because they're needed by `VcPkgManifestFeatures.cmake`.
Expand Down
17 changes: 16 additions & 1 deletion Packaging/nix/LinuxReleasePackaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@ set -x
BUILD_DIR="${1-build}"

mkdir -p "${BUILD_DIR}/package"
find "${BUILD_DIR}/_CPack_Packages/Linux/7Z/" -type f -name 'devilutionx' -exec cp "{}" "${BUILD_DIR}/devilutionx" \;

PKG_PATH=("${BUILD_DIR}/_CPack_Packages/Linux/7Z/"devilutionx-*/)
PKG_PATH="${PKG_PATH[@]}"
PKG_PATH="${PKG_PATH%/}"

cp "${PKG_PATH}/bin/devilutionx" "${BUILD_DIR}/package/devilutionx"
if [[ -f "${PKG_PATH}/lib/discord_game_sdk.so" ]]; then
cp "${PKG_PATH}/lib/discord_game_sdk.so" "${BUILD_DIR}/package/"
cat <<'SH' > "${BUILD_DIR}/package/devilutionx.sh"
#!/bin/sh
BASEDIR="$(dirname "$(realpath "$0")")"
LD_LIBRARY_PATH="$BASEDIR" "$BASEDIR"/devilutionx
SH
chmod +x "${BUILD_DIR}/package/devilutionx.sh"
fi

cp "${BUILD_DIR}/devilutionx" "${BUILD_DIR}/package/devilutionx"
cp "${BUILD_DIR}/devilutionx.mpq" "${BUILD_DIR}/package/devilutionx.mpq"

Expand Down
Binary file added Packaging/resources/assets/nlevels/cutl5w.clx
Binary file not shown.
Binary file added Packaging/resources/assets/nlevels/cutl6w.clx
Binary file not shown.
1 change: 1 addition & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ set(libdevilutionx_SRCS
utils/sdl_bilinear_scale.cpp
utils/sdl_thread.cpp
utils/str_cat.cpp
utils/str_case.cpp
utils/surface_to_clx.cpp
utils/utf8.cpp)

Expand Down
10 changes: 4 additions & 6 deletions Source/DiabloUI/diabloui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
namespace devilution {

OptionalOwnedClxSpriteList ArtLogo;
std::array<OptionalOwnedClxSpriteList, 2> DifficultyIndicator;
OptionalOwnedClxSpriteList DifficultyIndicator;

std::array<OptionalOwnedClxSpriteList, 3> ArtFocus;

Expand Down Expand Up @@ -481,7 +481,7 @@ void UiHandleEvents(SDL_Event *event)
HandleControllerAddedOrRemovedEvent(*event);

if (event->type == SDL_WINDOWEVENT) {
if (IsAnyOf(event->window.event, SDL_WINDOWEVENT_SHOWN, SDL_WINDOWEVENT_EXPOSED)) {
if (IsAnyOf(event->window.event, SDL_WINDOWEVENT_SHOWN, SDL_WINDOWEVENT_EXPOSED, SDL_WINDOWEVENT_RESTORED)) {
gbActive = true;
} else if (IsAnyOf(event->window.event, SDL_WINDOWEVENT_HIDDEN, SDL_WINDOWEVENT_MINIMIZED)) {
gbActive = false;
Expand Down Expand Up @@ -588,8 +588,7 @@ void LoadUiGFX()
} else {
ArtLogo = LoadPcxSpriteList("ui_art\\smlogo", /*numFrames=*/15, /*transparentColor=*/250);
}
DifficultyIndicator[0] = LoadPcx("ui_art\\radio1", /*transparentColor=*/0);
DifficultyIndicator[1] = LoadPcx("ui_art\\radio3", /*transparentColor=*/0);
DifficultyIndicator = LoadPcx("ui_art\\r1_gry", /*transparentColor=*/0);
ArtFocus[FOCUS_SMALL] = LoadPcxSpriteList("ui_art\\focus16", /*numFrames=*/8, /*transparentColor=*/250);
ArtFocus[FOCUS_MED] = LoadPcxSpriteList("ui_art\\focus", /*numFrames=*/8, /*transparentColor=*/250);
ArtFocus[FOCUS_BIG] = LoadPcxSpriteList("ui_art\\focus42", /*numFrames=*/8, /*transparentColor=*/250);
Expand Down Expand Up @@ -617,8 +616,7 @@ void UnloadUiGFX()
for (auto &art : ArtFocus)
art = std::nullopt;
ArtLogo = std::nullopt;
for (auto &diffInd : DifficultyIndicator)
diffInd = std::nullopt;
DifficultyIndicator = std::nullopt;
}

void UiInitialize()
Expand Down
2 changes: 1 addition & 1 deletion Source/DiabloUI/diabloui.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct _uiheroinfo {
};

extern OptionalOwnedClxSpriteList ArtLogo;
extern std::array<OptionalOwnedClxSpriteList, 2> DifficultyIndicator;
extern OptionalOwnedClxSpriteList DifficultyIndicator;
extern std::array<OptionalOwnedClxSpriteList, 3> ArtFocus;
extern OptionalOwnedClxSpriteList ArtBackgroundWidescreen;
extern OptionalOwnedClxSpriteList ArtBackground;
Expand Down
14 changes: 10 additions & 4 deletions Source/DiabloUI/hero/selhero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,17 @@ void RenderDifficultyIndicators()
{
if (!selhero_isSavegame)
return;
const uint16_t width = (*DifficultyIndicator[0])[0].width();
const uint16_t height = (*DifficultyIndicator[0])[0].height();
SDL_Rect rect = MakeSdlRect(SELHERO_DIALOG_HERO_IMG->m_rect.x, SELHERO_DIALOG_HERO_IMG->m_rect.y - height - 2, width, height);
const uint16_t width = (*DifficultyIndicator)[0].width();
const uint16_t height = (*DifficultyIndicator)[0].height();
SDL_Rect rect = MakeSdlRect(
SELHERO_DIALOG_HERO_IMG->m_rect.x + 1,
SELHERO_DIALOG_HERO_IMG->m_rect.y + SELHERO_DIALOG_HERO_IMG->m_rect.h - height - 1,
width,
height);
for (int i = 0; i <= DIFF_LAST; i++) {
UiRenderItem(UiImageClx((*DifficultyIndicator[i < selhero_heroInfo.herorank ? 0 : 1])[0], rect, UiFlags::None));
if (i >= selhero_heroInfo.herorank)
break;
UiRenderItem(UiImageClx((*DifficultyIndicator)[0], rect, UiFlags::None));
rect.x += width;
}
}
Expand Down
73 changes: 66 additions & 7 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "utils/log.hpp"
#include "utils/sdl_geometry.h"
#include "utils/stdcompat/optional.hpp"
#include "utils/str_case.hpp"
#include "utils/str_cat.hpp"
#include "utils/string_or_view.hpp"
#include "utils/utf8.hpp"
Expand Down Expand Up @@ -442,11 +443,9 @@ std::string TextCmdInspect(const string_view parameter)
return ret;
}

std::string param { parameter.data() };
std::transform(param.begin(), param.end(), param.begin(), [](unsigned char c) { return std::tolower(c); });
const std::string param = AsciiStrToLower(parameter);
for (auto &player : Players) {
std::string playerName { player._pName };
std::transform(playerName.begin(), playerName.end(), playerName.begin(), [](unsigned char c) { return std::tolower(c); });
const std::string playerName = AsciiStrToLower(player._pName);
if (playerName.find(param) != std::string::npos) {
InspectPlayer = &player;
StrAppend(ret, _("Inspecting player: "));
Expand All @@ -462,11 +461,71 @@ std::string TextCmdInspect(const string_view parameter)
return ret;
}

bool IsQuestEnabled(const Quest &quest)
{
switch (quest._qidx) {
case Q_FARMER:
return gbIsHellfire && !sgGameInitInfo.bCowQuest;
case Q_JERSEY:
return gbIsHellfire && sgGameInitInfo.bCowQuest;
case Q_GIRL:
return gbIsHellfire && sgGameInitInfo.bTheoQuest;
case Q_CORNSTN:
return gbIsHellfire && !gbIsMultiplayer;
case Q_GRAVE:
case Q_DEFILER:
case Q_NAKRUL:
return gbIsHellfire;
case Q_TRADER:
return false;
default:
return quest._qactive != QUEST_NOTAVAIL;
}
}

std::string TextCmdLevelSeed(const string_view parameter)
{
string_view levelType = setlevel ? "set level" : "dungeon level";

char gameId[] = {
static_cast<char>((sgGameInitInfo.programid >> 24) & 0xFF),
static_cast<char>((sgGameInitInfo.programid >> 16) & 0xFF),
static_cast<char>((sgGameInitInfo.programid >> 8) & 0xFF),
static_cast<char>(sgGameInitInfo.programid & 0xFF),
'\0'
};

string_view mode = gbIsMultiplayer ? "MP" : "SP";
string_view questPool = UseMultiplayerQuests() ? "MP" : "Full";

uint32_t questFlags = 0;
for (const Quest &quest : Quests) {
questFlags <<= 1;
if (IsQuestEnabled(quest))
questFlags |= 1;
}

return StrCat(
"Seedinfo for ", levelType, " ", currlevel, "\n",
"seed: ", glSeedTbl[currlevel], "\n",
#ifdef _DEBUG
"Mid1: ", glMid1Seed[currlevel], "\n",
"Mid2: ", glMid2Seed[currlevel], "\n",
"Mid3: ", glMid3Seed[currlevel], "\n",
"End: ", glEndSeed[currlevel], "\n",
#endif
"\n",
gameId, " ", mode, "\n",
questPool, " quests: ", questFlags, "\n",
"Storybook: ", glSeedTbl[16]);
}

std::vector<TextCmdItem> TextCmdList = {
{ N_("/help"), N_("Prints help overview or help for a specific command."), N_("({command})"), &TextCmdHelp },
{ N_("/arena"), N_("Enter a PvP Arena."), N_("{arena-number}"), &TextCmdArena },
{ N_("/arenapot"), N_("Gives Arena Potions."), N_("{number}"), &TextCmdArenaPot },
{ N_("/inspect"), N_("Inspects stats and equipment of another player."), N_("{player name}"), &TextCmdInspect },
{ N_("/seedinfo"), N_("Show seed infos for current level."), "", &TextCmdLevelSeed },
};

bool CheckTextCommand(const string_view text)
Expand Down Expand Up @@ -658,7 +717,7 @@ void OpenCharPanel()
{
QuestLogIsOpen = false;
CloseGoldWithdraw();
IsStashOpen = false;
CloseStash();
chrflag = true;
}

Expand Down Expand Up @@ -1032,7 +1091,7 @@ void CheckBtnUp()
case PanelButtonQlog:
CloseCharPanel();
CloseGoldWithdraw();
IsStashOpen = false;
CloseStash();
if (!QuestLogIsOpen)
StartQuestlog();
else
Expand All @@ -1049,7 +1108,7 @@ void CheckBtnUp()
case PanelButtonInventory:
sbookflag = false;
CloseGoldWithdraw();
IsStashOpen = false;
CloseStash();
invflag = !invflag;
if (dropGoldFlag) {
CloseGoldDrop();
Expand Down
12 changes: 8 additions & 4 deletions Source/controls/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "controls/devices/joystick.h"
#include "controls/devices/kbcontroller.h"

#include "engine/demomode.h"

namespace devilution {

void UnlockControllerState(const SDL_Event &event)
Expand Down Expand Up @@ -39,9 +41,11 @@ StaticVector<ControllerButtonEvent, 4> ToControllerButtonEvents(const SDL_Event
break;
}
#if HAS_KBCTRL == 1
result.button = KbCtrlToControllerButton(event);
if (result.button != ControllerButton_NONE)
return { result };
if (!demo::IsRunning()) {
result.button = KbCtrlToControllerButton(event);
if (result.button != ControllerButton_NONE)
return { result };
}
#endif
#ifndef USE_SDL1
GameController *const controller = GameController::Get(event);
Expand Down Expand Up @@ -71,7 +75,7 @@ bool IsControllerButtonPressed(ControllerButton button)
return true;
#endif
#if HAS_KBCTRL == 1
if (IsKbCtrlButtonPressed(button))
if (!demo::IsRunning() && IsKbCtrlButtonPressed(button))
return true;
#endif
return Joystick::IsPressedOnAnyJoystick(button);
Expand Down
1 change: 1 addition & 0 deletions Source/controls/controller_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "controls/game_controls.h"
#include "controls/plrctrls.h"
#include "controls/touch/gamepad.h"
#include "engine/demomode.h"
#include "options.h"
#include "utils/log.hpp"

Expand Down
4 changes: 2 additions & 2 deletions Source/controls/plrctrls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ void ProcessGameAction(const GameAction &action)
QuestLogIsOpen = false;
sbookflag = false;
CloseGoldWithdraw();
IsStashOpen = false;
CloseStash();
}
break;
case GameActionType_TOGGLE_CHARACTER_INFO:
Expand All @@ -1644,7 +1644,7 @@ void ProcessGameAction(const GameAction &action)
StartQuestlog();
CloseCharPanel();
CloseGoldWithdraw();
IsStashOpen = false;
CloseStash();
spselflag = false;
} else {
QuestLogIsOpen = false;
Expand Down
Loading

0 comments on commit 1b226bb

Please sign in to comment.