Skip to content

Commit

Permalink
Refactor: Removing Qt dependencies; updating for revised libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 9c37a39 commit 404ea36
Show file tree
Hide file tree
Showing 30 changed files with 504 additions and 462 deletions.
9 changes: 4 additions & 5 deletions doomsday/apps/client/include/misc/mesh.h
Expand Up @@ -20,9 +20,8 @@
#ifndef DATA_MESH_H
#define DATA_MESH_H

#include <QList>

#include <de/Error>
#include <de/List>
#include <de/Vector>

#include <doomsday/world/MapElement>
Expand All @@ -45,9 +44,9 @@ class HEdge;
class Mesh
{
public:
typedef QList<Vertex *> Vertexs;
typedef QList<Face *> Faces;
typedef QList<HEdge *> HEdges;
typedef List<Vertex *> Vertexs;
typedef List<Face *> Faces;
typedef List<HEdge *> HEdges;

/**
* Base class for all elements of a mesh.
Expand Down
18 changes: 9 additions & 9 deletions doomsday/apps/client/include/world/map.h
Expand Up @@ -23,9 +23,9 @@
#define DE_WORLD_MAP_H

#include <functional>
#include <QHash>
#include <QList>
#include <QSet>
#include <de/Hash>
#include <de/List>
#include <de/Set>
#include <doomsday/BspNode>
#include <doomsday/world/map.h>
#include <doomsday/world/ithinkermapping.h>
Expand Down Expand Up @@ -134,9 +134,9 @@ class Map : public world::BaseMap
/// Maximum number of generators per map.
static de::dint const MAX_GENERATORS = 512;

typedef QSet<Plane *> PlaneSet;
typedef QSet<Surface *> SurfaceSet;
typedef QHash<thid_t, struct mobj_s *> ClMobjHash;
typedef Set<Plane *> PlaneSet;
typedef Set<Surface *> SurfaceSet;
typedef Hash<thid_t, struct mobj_s *> ClMobjHash;
#endif

public: /// @todo make private:
Expand Down Expand Up @@ -949,19 +949,19 @@ class Map : public world::BaseMap
/**
* Provides a list of all the editable lines in the map.
*/
typedef QList<Line *> Lines;
typedef List<Line *> Lines;
Lines const &editableLines() const;

/**
* Provides a list of all the editable polyobjs in the map.
*/
typedef QList<Polyobj *> Polyobjs;
typedef List<Polyobj *> Polyobjs;
Polyobjs const &editablePolyobjs() const;

/**
* Provides a list of all the editable sectors in the map.
*/
typedef QList<Sector *> Sectors;
typedef List<Sector *> Sectors;
Sectors const &editableSectors() const;

inline de::dint editableLineCount () const { return editableLines ().count(); }
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/api_uri.cpp
Expand Up @@ -170,14 +170,14 @@ AutoStr* Uri_Resolved(Uri const* uri)
const Str* Uri_Scheme(Uri const* uri)
{
SELF_CONST(uri);
return self->schemeStr();
return AutoStr_FromTextStd(self->scheme());
}

#undef Uri_Path
const Str* Uri_Path(Uri const* uri)
{
SELF_CONST(uri);
return self->pathStr();
return AutoStr_FromTextStd(self->path());
}

#undef Uri_SetUri2
Expand Down
8 changes: 3 additions & 5 deletions doomsday/apps/client/src/misc/mesh.cpp
Expand Up @@ -22,8 +22,6 @@
#include "Face"
#include "Vertex"

#include <QtAlgorithms>

namespace de {

Mesh::Element::Element(Mesh &owner)
Expand Down Expand Up @@ -76,9 +74,9 @@ Mesh::~Mesh()

void Mesh::clear()
{
qDeleteAll(d->vertexs); d->vertexs.clear();
qDeleteAll(d->hedges); d->hedges.clear();
qDeleteAll(d->faces); d->faces.clear();
deleteAll(d->vertexs); d->vertexs.clear();
deleteAll(d->hedges); d->hedges.clear();
deleteAll(d->faces); d->faces.clear();
}

Vertex *Mesh::newVertex(Vec2d const &origin)
Expand Down
101 changes: 61 additions & 40 deletions doomsday/apps/client/src/ui/nativeui.cpp
Expand Up @@ -19,41 +19,45 @@
* 02110-1301 USA</small>
*/

#include <QMessageBox>
#include <QFile>
#include <QString>
#include <stdarg.h>
#include "dd_share.h"
#include "sys_system.h"
#include <QLayout>
#include <QLabel>
#include <QVBoxLayout>
#include <QDebug>
#include "ui/nativeui.h"
#include "ui/clientwindow.h"

#include <de/App>
#include <de/ByteArrayFile>
#include <de/FileSystem>
#include <SDL2/SDL_messagebox.h>
#include <stdarg.h>

#include "ui/nativeui.h"
#include "ui/clientwindow.h"

void Sys_MessageBox(messageboxtype_t type, const char* title, const char* msg, const char* detailedMsg)
void Sys_MessageBox(messageboxtype_t type,
const char * title,
const char * msg,
const char * detailedMsg)
{
Sys_MessageBox2(type, title, msg, 0, detailedMsg);
}

void Sys_MessageBox2(messageboxtype_t type, const char* title, const char* msg, const char* informativeMsg, const char* detailedMsg)
void Sys_MessageBox2(messageboxtype_t type,
const char * title,
const char * msg,
const char * informativeMsg,
const char * detailedMsg)
{
Sys_MessageBox3(type, title, msg, informativeMsg, detailedMsg, 0);
}

int Sys_MessageBox3(messageboxtype_t type, const char* title, const char* msg, const char* informativeMsg, const char* detailedMsg,
const char** buttons)
int Sys_MessageBox3(messageboxtype_t type,
const char * title,
const char * msg,
const char * informativeMsg,
const char * detailedMsg,
const char ** buttons)
{
if (novideo)
{
// There's no GUI...
qWarning("%s", msg);
de::warning("%s", msg);
return 0;
}

Expand All @@ -62,40 +66,52 @@ int Sys_MessageBox3(messageboxtype_t type, const char* title, const char* msg, c
ClientWindow::main().hide();
}

QMessageBox box;
box.setWindowTitle(title);
box.setText(msg);
SDL_MessageBoxData box{};
box.title = title;

switch (type)
{
case MBT_INFORMATION: box.setIcon(QMessageBox::Information); break;
case MBT_QUESTION: box.setIcon(QMessageBox::Question); break;
case MBT_WARNING: box.setIcon(QMessageBox::Warning); break;
case MBT_ERROR: box.setIcon(QMessageBox::Critical); break;
case MBT_INFORMATION: box.flags = SDL_MESSAGEBOX_INFORMATION; break;
case MBT_QUESTION: box.flags = SDL_MESSAGEBOX_INFORMATION; break;
case MBT_WARNING: box.flags = SDL_MESSAGEBOX_WARNING; break;
case MBT_ERROR: box.flags = SDL_MESSAGEBOX_ERROR; break;
default:
break;
}

de::String text = msg;
if (detailedMsg)
{
/// @todo Making the dialog a bit wider would be nice, but it seems one has to
/// derive a new message box class for that -- the default one has a fixed size.

box.setDetailedText(detailedMsg);
text += "\n\n";
text += detailedMsg;
}
if (informativeMsg)
{
box.setInformativeText(informativeMsg);
text += "\n\n";
text += informativeMsg;
}
box.message = text;

std::vector<SDL_MessageBoxButtonData> buttonData;
if (buttons)
{
for (int i = 0; buttons[i]; ++i)
{
box.addButton(buttons[i],
i == 0? QMessageBox::AcceptRole :
i == 1? QMessageBox::RejectRole :
QMessageBox::ActionRole);
buttonData.emplace_back( i == 0 ? SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT
: i == 1 ? SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT : 0,
i,
buttons[i]);
}
}
return box.exec();
else
{
buttonData.emplace_back(SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "OK");
}
int rc;
SDL_ShowMessageBox(&box, &rc);
return rc;
}

void Sys_MessageBoxf(messageboxtype_t type, const char* title, const char* format, ...)
Expand All @@ -110,29 +126,34 @@ void Sys_MessageBoxf(messageboxtype_t type, const char* title, const char* forma
Sys_MessageBox(type, title, buffer, 0);
}

int Sys_MessageBoxWithButtons(messageboxtype_t type, const char* title, const char* msg,
const char* informativeMsg, const char** buttons)
int Sys_MessageBoxWithButtons(messageboxtype_t type,
const char * title,
const char * msg,
const char * informativeMsg,
const char ** buttons)
{
return Sys_MessageBox3(type, title, msg, informativeMsg, 0, buttons);
}

void Sys_MessageBoxWithDetailsFromFile(messageboxtype_t type, const char* title, const char* msg,
const char* informativeMsg, const char* detailsFileName)
void Sys_MessageBoxWithDetailsFromFile(messageboxtype_t type,
const char * title,
const char * msg,
const char * informativeMsg,
const char * detailsFileName)
{
try
{
de::Block details;
de::ByteArrayFile const &file = de::App::rootFolder().locate<de::ByteArrayFile>(detailsFileName);
file >> details;
de::String details;
de::App::rootFolder().locate<const de::File>(detailsFileName) >> details;

// This will be used as a null-terminated string.
details.append('\0');

Sys_MessageBox2(type, title, msg, informativeMsg, details.constData());
Sys_MessageBox2(type, title, msg, informativeMsg, details);
}
catch (de::Error const &er)
{
qWarning() << "Could not read" << detailsFileName << ":" << er.asText().toLatin1().constData();
de::warning("Could not read \"%s\": %s", detailsFileName, er.asText().c_str());

// Show it without the details, then.
Sys_MessageBox2(type, title, msg, informativeMsg, 0);
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/world/base/map.cpp
Expand Up @@ -77,6 +77,7 @@
#include <doomsday/BspNode>
#include <doomsday/world/Materials>

#include <de/BitArray>
#include <de/LogBuffer>
#include <de/Rectangle>

Expand All @@ -87,9 +88,8 @@
#include <de/timer.h>

#include <array>
#include <QBitArray>
#include <QMultiMap>
#include <QVarLengthArray>
#include <map>
//#include <QVarLengthArray>

using namespace de;

Expand Down
5 changes: 3 additions & 2 deletions doomsday/apps/gloom/CMakeLists.txt
Expand Up @@ -4,8 +4,9 @@ project (GLOOM)
include (../../cmake/Config.cmake)
include (QtConfig)

find_package (Qt5 COMPONENTS Gui Widgets Network OpenGL OpenGLExtensions)
find_package (Qt5 COMPONENTS Gui Widgets)
find_package (FMOD)
find_package (glbinding REQUIRED)

list (APPEND DE_REQUIRED_PACKAGES
net.dengine.stdlib
Expand Down Expand Up @@ -106,7 +107,7 @@ endif ()
deng_add_application (gloom ${SOURCES} ${HEADERS})

target_include_directories (gloom PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${DE_EXTERNAL_SOURCE_DIR}/gpc)
deng_link_libraries (gloom PRIVATE DengAppfw DengDoomsday fmodex)
deng_link_libraries (gloom PRIVATE DengAppfw DengDoomsday fmodex glbinding::glbinding)
deng_target_link_qt (gloom PRIVATE Widgets)

if (APPLE)
Expand Down
9 changes: 6 additions & 3 deletions doomsday/apps/gloom/gloom/audio/audiosystem.cpp
Expand Up @@ -7,6 +7,7 @@
#include <fmod.hpp>
#include <fmod_errors.h>
#include <QHash>
#include <QSet>

using namespace de;

Expand Down Expand Up @@ -157,7 +158,7 @@ DE_PIMPL(AudioSystem)
wf.bitsPerSample() == 16? FMOD_SOUND_FORMAT_PCM16 :
wf.bitsPerSample() == 24? FMOD_SOUND_FORMAT_PCM24 :
FMOD_SOUND_FORMAT_PCM32);
system->createSound(wf.sampleData().constData(),
system->createSound(wf.sampleData().c_str(),
FMOD_OPENRAW | FMOD_OPENMEMORY_POINT | commonFlags,
&info, &sound);
}
Expand All @@ -173,8 +174,10 @@ DE_PIMPL(AudioSystem)

// Compressed sound formats might be understood by FMOD.
FMOD_RESULT result = system->createSound(
reinterpret_cast<char const *>(wf.sourceFile()->path().constData()),
/*FMOD_UNICODE |*/ FMOD_CREATECOMPRESSEDSAMPLE | commonFlags, &info, &sound);
wf.sourceFile()->path().c_str(),
/*FMOD_UNICODE |*/ FMOD_CREATECOMPRESSEDSAMPLE | commonFlags,
&info,
&sound);
if(result != FMOD_OK)
{
LOG_AUDIO_WARNING("Failed to load %s: %s")
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/plugins/common/include/g_common.h
Expand Up @@ -86,7 +86,7 @@ void G_SetGameActionMapCompleted(res::Uri const &nextMapUri, uint nextMapEntryPo
/**
* @param episodeId Identifier of the episode to lookup the title of.
*/
de::String G_EpisodeTitle(de::String episodeId);
de::String G_EpisodeTitle(const de::String& episodeId);

/**
* Returns the effective map-info definition Record associated with the given
Expand Down Expand Up @@ -122,7 +122,7 @@ res::Uri G_MapTitleImage(res::Uri const &mapUri);
*
* @return Rich-formatted description of the map.
*/
de::String G_MapDescription(de::String episodeId, res::Uri const &mapUri);
de::String G_MapDescription(const de::String& episodeId, res::Uri const &mapUri);

/**
* Attempt to extract the logical map number encoded in the @a mapUri. Assumes the default
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/plugins/common/include/gamesession.h
Expand Up @@ -106,7 +106,7 @@ class GameSession : public AbstractSession
/**
* Resolves a named exit according to the map progression.
*/
res::Uri mapUriForNamedExit(de::String name) const;
res::Uri mapUriForNamedExit(const de::String& name) const;

/**
* Returns the current ruleset for the game session.
Expand Down

0 comments on commit 404ea36

Please sign in to comment.