Skip to content

Commit

Permalink
GameKit: Added Doom as a static library
Browse files Browse the repository at this point in the history
Work in progress. The extension and its entry points need to be registered.
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 413b028 commit 5c08aeb
Show file tree
Hide file tree
Showing 25 changed files with 150 additions and 79 deletions.
2 changes: 1 addition & 1 deletion doomsday/apps/api/doomsday.h
Expand Up @@ -57,7 +57,7 @@
#include <doomsday/player.h>

#include <de/legacy/memoryzone.h>
#include <de/point.h>
#include <de/legacy/point.h>
#include <de/legacy/reader.h>
#include <de/legacy/rect.h>
#include <de/legacy/size.h>
Expand Down
1 change: 1 addition & 0 deletions doomsday/cmake/PlatformMacx.cmake
Expand Up @@ -50,6 +50,7 @@ if (CLANG_VERSION_STRING VERSION_EQUAL 7.0 OR
append_unique (CMAKE_CXX_FLAGS "-Wno-nested-anon-types")
endif ()

# All symbols are hidden by default.
append_unique (CMAKE_CXX_FLAGS "-fvisibility=hidden")

set (DE_FIXED_ASM_DEFAULT OFF)
Expand Down
4 changes: 0 additions & 4 deletions doomsday/libs/core/src/core/library.cpp
Expand Up @@ -22,10 +22,6 @@
#include "de/Log"
#include "de/LogBuffer"

#if !defined (DE_STATIC_LINK)
//# include <QLibrary>
#endif

#include <array>

namespace de {
Expand Down
5 changes: 5 additions & 0 deletions doomsday/libs/gamekit/CMakeLists.txt
Expand Up @@ -4,6 +4,8 @@ cmake_minimum_required (VERSION 3.1)
project (DE_LIBGAMEKIT)
include (../../cmake/Config.cmake)

add_subdirectory (libs/doom)

# Definitions.
add_definitions (
-D__LIBGAMEFW__=1
Expand All @@ -20,6 +22,9 @@ deng_merge_sources (libgamekit src/*.cpp)
deng_add_library (libgamekit ${SOURCES} ${HEADERS})
deng_link_libraries (libgamekit PUBLIC DengCore)

# Game modules.
target_link_libraries (libgamekit PRIVATE doom)

if (DE_ENABLE_SDK)
install (DIRECTORY include/gamefw
DESTINATION include
Expand Down
111 changes: 111 additions & 0 deletions doomsday/libs/gamekit/libs/GameConfig.cmake
@@ -0,0 +1,111 @@
# The Doomsday Engine Project -- Common build config for plugins
# Copyright (c) 2015-2017 Jaakko Keränen <jaakko.keranen@iki.fi>

cmake_minimum_required (VERSION 3.0)
project (DE_GAMEKIT_LIBS)
include (${CMAKE_CURRENT_LIST_DIR}/../../../cmake/Config.cmake)

macro (deng_add_gamelib target)
sublist (_src 1 -1 ${ARGV})
# if (WIN32)
# # Find the exports .def and .rc files.
# set (_exports "${CMAKE_CURRENT_SOURCE_DIR}/api/${target}.def")
# if (NOT EXISTS ${_exports})
# message (WARNING "Plugin \"${target}\" is missing the exports .def file.")
# endif ()
# list (APPEND _src ${_exports})
# set (_winres "${CMAKE_CURRENT_SOURCE_DIR}/res/${target}.rc")
# if (NOT EXISTS ${_winres})
# message (WARNING "Plugin \"${target}\" is missing the resource .rc file.")
# endif ()
# list (APPEND _src ${_winres})
# endif ()
# if (DE_STATIC_LINK)
set (_libType STATIC)
# else ()
# set (_libType MODULE)
# endif ()
add_library (${target} STATIC ${_src} ${DE_RESOURCES})
target_include_directories (${target}
PUBLIC "${DE_API_DIR}"
PRIVATE "${DE_SOURCE_DIR}/libs/gui/include" "${DE_SOURCE_DIR}/libs/gamekit/include"
)
deng_link_libraries (${target} PRIVATE DengDoomsday) # DengGamefw)
enable_cxx11 (${target})
set_target_properties (${target} PROPERTIES FOLDER Plugins)

if (APPLE)
# if (IOS)
# set_property (TARGET ${target} PROPERTY XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING NO)
# link_framework (${target} PUBLIC Foundation)
# link_framework (${target} PUBLIC CoreFoundation)
# link_framework (${target} PUBLIC MobileCoreServices)
# link_framework (${target} PUBLIC UIKit)
# link_framework (${target} PUBLIC Security)
# target_link_libraries (${target} PUBLIC
# debug ${QT_LIBS}/libqtpcre_debug.a
# optimized ${QT_LIBS}/libqtpcre.a
# )
# endif ()
# The plugins have some messy code.
set_property (TARGET ${target}
APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-braces
)
# set (_extraRPath)
# if (NOT DE_ENABLE_DEPLOYQT)
# set (_extraRPath ${QT_LIBS})
# endif ()
# set_target_properties (${target} PROPERTIES
# BUNDLE ON
# MACOSX_BUNDLE_INFO_PLIST ${DE_SOURCE_DIR}/cmake/MacOSXPluginBundleInfo.plist.in
# BUILD_WITH_INSTALL_RPATH ON # staging prevents CMake's own rpath fixing
# INSTALL_RPATH "@loader_path/../Frameworks;@executable_path/../Frameworks;${_extraRPath}"
# )
# set (_extraRPath)
# macx_set_bundle_name ("net.dengine.plugin.${target}")
# if (IOS)
# set (MACOSX_BUNDLE_BUNDLE_EXECUTABLE "${target}.bundle/${target}")
# else ()
# set (MACOSX_BUNDLE_BUNDLE_EXECUTABLE "${target}.bundle/Contents/MacOS/${target}")
# endif ()

# Stage plugins for symlinking/copying into the client app later.
# This is needed because we want access to these even in a build where the
# plugins are not installed yet -- the staging directory symlinks to the
# individual build directories.
# set (stage "${DE_BUILD_STAGING_DIR}/DengPlugins")
# add_custom_command (TARGET ${target} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E make_directory "${stage}"
# COMMAND ${CMAKE_COMMAND} -E create_symlink
# "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${target}.bundle"
# "${stage}/${target}.bundle"
# )
deng_xcode_attribs (${target})
deng_bundle_resources ()
else ()
set_target_properties (${target} PROPERTIES
VERSION ${DE_VERSION}
)
deng_target_rpath (${target})
endif ()

# if (MSVC)
# set_target_properties (${target} PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY_DEBUG "${DE_VS_STAGING_DIR}/Debug/${DE_INSTALL_PLUGIN_DIR}"
# RUNTIME_OUTPUT_DIRECTORY_RELEASE "${DE_VS_STAGING_DIR}/Release/${DE_INSTALL_PLUGIN_DIR}"
# RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${DE_VS_STAGING_DIR}/MinSizeRel/${DE_INSTALL_PLUGIN_DIR}"
# RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${DE_VS_STAGING_DIR}/RelWithDebInfo/${DE_INSTALL_PLUGIN_DIR}"
#
# LIBRARY_OUTPUT_DIRECTORY_DEBUG "${DE_VS_STAGING_DIR}/Debug/${DE_INSTALL_PLUGIN_DIR}"
# LIBRARY_OUTPUT_DIRECTORY_RELEASE "${DE_VS_STAGING_DIR}/Release/${DE_INSTALL_PLUGIN_DIR}"
# LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${DE_VS_STAGING_DIR}/MinSizeRel/${DE_INSTALL_PLUGIN_DIR}"
# LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${DE_VS_STAGING_DIR}/RelWithDebInfo/${DE_INSTALL_PLUGIN_DIR}"
# )
# endif ()

# if (NOT APPLE)
# install (TARGETS ${target} LIBRARY DESTINATION ${DE_INSTALL_PLUGIN_DIR})
# endif ()
# set (_src)
# set (_script)
endmacro (deng_add_gamelib)
21 changes: 0 additions & 21 deletions doomsday/libs/gamekit/libs/common/include/gl_special.h

This file was deleted.

7 changes: 2 additions & 5 deletions doomsday/libs/gamekit/libs/common/include/menu/page.h
Expand Up @@ -63,11 +63,8 @@ class Page

using Children = WidgetList;

typedef void (*OnActiveCallback) (Page &);
typedef void (*OnDrawCallback) (Page const &, de::Vec2i const &);

using OnActiveCallback = std::function<void(Page &)>;
using OnDrawCallback = std::function<void(Page const &, de::Vector2i const &)>;
using OnDrawCallback = std::function<void(Page const &, de::Vec2i const &)>;
using CommandResponder = std::function<int(Page &, menucommand_e)>;

public:
Expand All @@ -82,7 +79,7 @@ class Page
*/
explicit Page(de::String name,
const de::Vec2i & origin = {},
Flags const & flags = DefaultFlags,
Flags flags = DefaultFlags,
const OnDrawCallback & drawer = {},
const CommandResponder &cmdResponder = {});

Expand Down
8 changes: 4 additions & 4 deletions doomsday/libs/gamekit/libs/common/include/r_special.h
Expand Up @@ -21,16 +21,16 @@

#include <de/libcore.h>

DENG2_EXTERN_C void R_SpecialFilterRegister(void);
DE_EXTERN_C void R_SpecialFilterRegister(void);

DENG2_EXTERN_C void R_InitSpecialFilter(void);
DE_EXTERN_C void R_InitSpecialFilter(void);

/**
* Draws a special filter over the screen (e.g. the Doom inversing filter used
* when in god mode).
*/
DENG2_EXTERN_C void R_UpdateSpecialFilter(int player);
DE_EXTERN_C void R_UpdateSpecialFilter(int player);

DENG2_EXTERN_C void R_UpdateSpecialFilterWithTimeDelta(int player, float delta);
DE_EXTERN_C void R_UpdateSpecialFilterWithTimeDelta(int player, float delta);

#endif // LIBCOMMON_REFRESH_SPECIAL_H
6 changes: 3 additions & 3 deletions doomsday/libs/gamekit/libs/common/src/game/gamesession.cpp
Expand Up @@ -123,7 +123,7 @@ DE_PIMPL(GameSession)

inline String userSavePath(String const &fileName)
{
DENG_ASSERT(DoomsdayApp::currentGameProfile());
DE_ASSERT(DoomsdayApp::currentGameProfile());
return SaveGames::savePath() / fileName + ".save";
}

Expand Down Expand Up @@ -1432,9 +1432,9 @@ void GameSession::consoleRegister() // static

} // namespace common

DENG_EXTERN_C unsigned int gfw_MapInfoFlags(void)
DE_EXTERN_C unsigned int gfw_MapInfoFlags(void)
{
return gfw_Session()->mapInfo().getui(QStringLiteral("flags"));
return gfw_Session()->mapInfo().getui(DE_STR("flags"));
}

String gfw_GameId()
Expand Down
17 changes: 0 additions & 17 deletions doomsday/libs/gamekit/libs/common/src/gl_special.cpp

This file was deleted.

4 changes: 2 additions & 2 deletions doomsday/libs/gamekit/libs/common/src/hu_menu.cpp
Expand Up @@ -27,7 +27,7 @@
#include <cstdio>
#include <cstring>
#include <de/Map>
#include <de/memory.h>
#include <de/legacy/memory.h>
#include <de/RecordValue>
#include <de/TextValue>
#include <de/NativePointerValue>
Expand Down Expand Up @@ -1519,7 +1519,7 @@ void Hu_MenuInitHUDOptionsPage()
page->addWidget(new LabelWidget("Text Color"))
.setLeft()
.setGroup(6);
page->addWidget(new CVarColorEditWidget("hud-color-r", "hud-color-g", "hud-color-b", "hud-color-a", Vector4f(), true))
page->addWidget(new CVarColorEditWidget("hud-color-r", "hud-color-g", "hud-color-b", "hud-color-a", {}, true))
.setRight()
.setGroup(6)
.setAction(Widget::Deactivated, CVarColorEditWidget_UpdateCVar)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/gamekit/libs/common/src/hu_msg.cpp
Expand Up @@ -23,7 +23,7 @@
#include "common.h"
#include <cstdlib>
#include <cstring>
#include <de/memory.h>
#include <de/legacy/memory.h>
#include "hu_msg.h"
#include "hu_menu.h"
#include "hu_stuff.h"
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/gamekit/libs/common/src/hud/hudwidget.cpp
Expand Up @@ -21,7 +21,7 @@
#include "common.h"
#include "hud/hudwidget.h"

#include <de/memory.h>
#include <de/legacy/memory.h>
#include "hud/widgets/groupwidget.h" ///< @todo remove me

using namespace de;
Expand Down
12 changes: 6 additions & 6 deletions doomsday/libs/gamekit/libs/common/src/menu/page.cpp
Expand Up @@ -147,7 +147,7 @@ DE_PIMPL(Page)
int prevGroup = children.front()->group();
Widget * prevWidget = nullptr;
int usedColumns = 0; // column flags for current row
Vector2i origin;
Vec2i origin;
int rowHeight = 0;

for (auto *wi : children)
Expand Down Expand Up @@ -365,8 +365,8 @@ DE_PIMPL(Page)
};

Page::Page(String name,
Vector2i const & origin,
Flags const & flags,
const Vec2i & origin,
Flags flags,
const OnDrawCallback & drawer,
const CommandResponder &cmdResponder)
: d(new Impl(this))
Expand Down Expand Up @@ -539,8 +539,8 @@ void Page::draw(float alpha, bool showFocusCursor)
if (!(d->flags & NoScroll) && focused)
{
// Determine available screen region for the page.
d->viewRegion.topLeft = Vector2i(0, 0); //d->origin.y);
d->viewRegion.setSize(Vector2ui(SCREENWIDTH, SCREENHEIGHT - d->origin.y - 35 /*arbitrary but enough for the help message*/));
d->viewRegion.topLeft = {0, 0}; //d->origin.y);
d->viewRegion.setSize(Vec2ui(SCREENWIDTH, SCREENHEIGHT - d->origin.y - 35 /*arbitrary but enough for the help message*/));

// Is scrolling in effect?
if (d->geometry.height() > d->viewRegion.height())
Expand Down Expand Up @@ -596,7 +596,7 @@ void Page::draw(float alpha, bool showFocusCursor)
// How about some additional help/information for the focused item?
if (focused && !focused->helpInfo().isEmpty())
{
Vector2i helpOrigin(SCREENWIDTH / 2, SCREENHEIGHT - 5 / cfg.common.menuScale);
Vec2i helpOrigin(SCREENWIDTH / 2, SCREENHEIGHT - 5 / cfg.common.menuScale);
Hu_MenuDrawPageHelp(focused->helpInfo(), helpOrigin);
}
}
Expand Down
Expand Up @@ -224,7 +224,7 @@ DE_PIMPL(InputBindingWidget)
}
}

Vector2ui measureAndDraw(bool drawing = true) const
Vec2ui measureAndDraw(bool drawing = true) const
{
const auto widgetTopLeft = self().geometry().topLeft;

Expand Down
Expand Up @@ -151,7 +151,6 @@ void ListWidget::draw() const
do
{
const Item *item = d->items[itemIdx];
Vec4f const &color = d->selection == itemIdx? (flashSelection? flashColor : textColor) : dimColor;

const Vec4f &color =
d->selection == itemIdx ? (flashSelection ? flashColor : textColor) : dimColor;
Expand All @@ -163,7 +162,7 @@ void ListWidget::draw() const
color.y,
color.z,
color.w * scrollingFadeout(origin.y, origin.y + itemHeight));
FR_DrawTextXY3(item->text().toUtf8().constData(), origin.x, origin.y, ALIGN_TOPLEFT, Hu_MenuMergeEffectWithDrawTextFlags(0));
FR_DrawTextXY3(item->text(), origin.x, origin.y, ALIGN_TOPLEFT, Hu_MenuMergeEffectWithDrawTextFlags(0));
origin.y += itemHeight;
} while (++itemIdx < d->items.count() && itemIdx < d->first + d->numvis);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/gamekit/libs/common/src/network/d_netsv.cpp
Expand Up @@ -25,7 +25,7 @@
#include <cctype>
#include <cstdio>
#include <cstring>
#include <de/mathutil.h>
#include <de/legacy/mathutil.h>

#include "d_net.h"
#include "gamesession.h"
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/gamekit/libs/common/src/p_inventory.cpp
Expand Up @@ -23,7 +23,7 @@
#include "p_inventory.h"

#include <cstring>
#include <de/memory.h>
#include <de/legacy/memory.h>
#include "d_net.h"
#include "d_netcl.h"
#include "g_common.h"
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/gamekit/libs/common/src/p_saveg.cpp
Expand Up @@ -29,7 +29,7 @@
#include "mapstatereader.h"
#include "mapstatewriter.h"
#include <de/String>
#include <de/memory.h>
#include <de/legacy/memory.h>
#include <cstdio>
#include <cstring>

Expand Down

0 comments on commit 5c08aeb

Please sign in to comment.