Skip to content

Commit

Permalink
Refactor|libcommon: Switched hu_inventory.c, gl_drawpatch.c to C++ pl…
Browse files Browse the repository at this point in the history
…us cleanup
  • Loading branch information
danij-deng committed Dec 5, 2014
1 parent 8e839a3 commit 8c93cf2
Show file tree
Hide file tree
Showing 18 changed files with 483 additions and 647 deletions.
4 changes: 2 additions & 2 deletions doomsday/plugins/common/common.pri
Expand Up @@ -107,11 +107,11 @@ SOURCES += \
$$common_src/g_update.cpp \
$$common_src/gamerules.cpp \
$$common_src/gamesession.cpp \
$$common_src/gl_drawpatch.c \
$$common_src/gl_drawpatch.cpp \
$$common_src/hexlex.cpp \
$$common_src/hu_automap.cpp \
$$common_src/hu_chat.cpp \
$$common_src/hu_inventory.c \
$$common_src/hu_inventory.cpp \
$$common_src/hu_lib.cpp \
$$common_src/hu_log.cpp \
$$common_src/hu_menu.cpp \
Expand Down
69 changes: 24 additions & 45 deletions doomsday/plugins/common/include/gl_drawpatch.h
@@ -1,42 +1,32 @@
/**\file gl_drawpatch.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/** @file gl_drawpatch.h Convenient drawing of Patch-textured quads.
*
*\author Copyright © 1999-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 1999-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2014 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* 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 St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

/**
* Convenient methods for drawing quads textured with Patch graphics.
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#ifndef LIBCOMMON_GRAPHICS_DRAW_PATCH_H
#define LIBCOMMON_GRAPHICS_DRAW_PATCH_H
#ifdef __cplusplus

#include <de/Vector>
#include "doomsday.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @defgroup drawPatchFlags Draw Patch Flags.
* @defgroup drawPatchFlags Draw Patch Flags.
*/
/*@{*/
#define DPF_NO_OFFSETX 0x0010
Expand All @@ -45,24 +35,13 @@ extern "C" {
/*@}*/

/**
* @param patchId Unique identifier of the patch to be drawn.
* @param origin Orient drawing about this offset (topleft:[0,0]).
* @param patchId Unique identifier of the patch to be drawn.
* @param origin Orient drawing about this offset (topleft:[0,0]).
* @param alignFlags @ref alignmentFlags
* @param patchFlags @ref drawPatchFlags
*/
void GL_DrawPatch3(patchid_t id, const Point2Raw* origin, int alignFlags, int patchFlags);
void GL_DrawPatch2(patchid_t id, const Point2Raw* origin, int alignFlags);
void GL_DrawPatch(patchid_t id, const Point2Raw* origin);

/**
* Same as @a GL_DrawPatch except origin is specified with separate xy coordinates.
*/
void GL_DrawPatchXY3(patchid_t id, int x, int y, int alignFlags, int patchFlags);
void GL_DrawPatchXY2(patchid_t id, int x, int y, int alignFlags);
void GL_DrawPatchXY(patchid_t id, int x, int y);

#ifdef __cplusplus
} // extern "C"
#endif
void GL_DrawPatch(patchid_t id, de::Vector2i const &origin,
int alignFlags = ALIGN_TOPLEFT, int patchFlags = 0);

#endif /* LIBCOMMON_GRAPHICS_DRAW_PATCH_H */
#endif // __cplusplus
#endif // LIBCOMMON_GRAPHICS_DRAW_PATCH_H
86 changes: 46 additions & 40 deletions doomsday/plugins/common/include/hu_inventory.h
@@ -1,59 +1,65 @@
/**\file
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/** @file hu_inventory.h HUD player inventory widget.
*
*\author Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2014 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* 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 St, Fifth Floor,
* Boston, MA 02110-1301 USA
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

/**
* hu_inventory.h: Heads-up display(s) for the player inventory.
*/

#ifndef __COMMON_HUD_INVENTORY__
#define __COMMON_HUD_INVENTORY__

#ifndef LIBCOMMON_HUD_INVENTORY
#define LIBCOMMON_HUD_INVENTORY
#if __JHERETIC__ || __JHEXEN__

#ifdef __cplusplus
extern "C" {
#endif

void Hu_InventoryRegister(void);
void Hu_InventoryInit(void);
void Hu_InventoryTicker(void);
void Hu_InventoryInit(void);

void Hu_InventoryOpen(int player, dd_bool show);
dd_bool Hu_InventoryIsOpen(int player);
dd_bool Hu_InventorySelect(int player, inventoryitemtype_t type);
dd_bool Hu_InventoryMove(int player, int dir, dd_bool canWrap,
dd_bool silent);
void Hu_InventoryDraw(int player, int x, int y, float textAlpha, float iconAlpha);
void Hu_InventoryDraw2(int player, int x, int y, float alpha);
void Hu_InventoryTicker(void);

/// \todo refactor this away.
void Hu_InventoryMarkDirty(int player);
void Hu_InventoryOpen(int player, dd_bool show);

dd_bool Hu_InventoryIsOpen(int player);

dd_bool Hu_InventorySelect(int player, inventoryitemtype_t type);

dd_bool Hu_InventoryMove(int player, int dir, dd_bool canWrap, dd_bool silent);

void Hu_InventoryDraw(int player, int x, int y, float textAlpha, float iconAlpha);
void Hu_InventoryDraw2(int player, int x, int y, float alpha);

/**
* Mark the HUD inventory as dirty (i.e., the player inventory state has
* changed in such a way that would require the HUD inventory display(s)
* to be updated e.g., the player gains a new item).
*
* @param player Player whoose in HUD inventory is dirty.
*
* @todo refactor away.
*/
void Hu_InventoryMarkDirty(int player);

/**
* Register the console commands and variables of this module.
*/
void Hu_InventoryRegister(void);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // __JHERETIC__ || __JHEXEN__

#endif
#endif // LIBCOMMON_HUD_INVENTORY
30 changes: 15 additions & 15 deletions doomsday/plugins/common/include/hu_stuff.h
Expand Up @@ -144,18 +144,18 @@ enum patchreplacemode_t
* @defgroup patchReplacementFlags Patch Replacement Flags.
* @{
*/
#define PRF_NO_IWAD 0x1 ///< Allow if resource does not originate from an IWAD.
#define PRF_NO_PWAD 0x2 ///< Allow if resource does not originate from a PWAD/external source.
#define PRF_NO_IWAD 0x1 ///< Allow if resource does not originate from an IWAD.
#define PRF_NO_PWAD 0x2 ///< Allow if resource does not originate from a PWAD/external source.
/**@}*/

/**
* Given a unique patch identifier (@a id) lookup a patch replacement string
* associated with this.
*
* @param patchId Unique patch identifier.
* @param flags @ref patchReplacementFlags
* @param patchId Unique patch identifier.
* @param flags @ref patchReplacementFlags
*
* @return Patch replacement string if defined/found else @c NULL.
* @return Patch replacement string if defined/found else @c nullptr.
*/
char const *Hu_FindPatchReplacementString(patchid_t patchId, int flags);

Expand All @@ -165,23 +165,23 @@ char const *Hu_FindPatchReplacementString(patchid_t patchId, int flags);
*
* @note If the patch does not originate from an IWAD it will not be replaced.
*
* @param replaceMode Replacement mode.
* @param patchId Unique identifier of the patch to choose a replacement for.
* @param text A prechoosen string replacement to be used if appropriate.
* @param replaceMode Replacement mode.
* @param patchId Unique identifier of the patch to choose a replacement for.
* @param text A prechoosen string replacement to be used if appropriate.
*/
de::String Hu_ChoosePatchReplacement(patchreplacemode_t replaceMode, patchid_t patchId,
de::String const &text = "");

/**
* Implements patch replacement.
*
* @param patchId Unique identifier of the patch to be drawn if no replacement.
* @param replacement Patch replacement string. Will be drawn instead of the
* patch if not @c NULL.
* @param origin Orient drawing about this offset (topleft:[0,0]).
* @param alignFlags @ref alignmentFlags
* @param patchFlags @ref drawPatchFlags
* @param textFlags @ref drawTextFlags
* @param patchId Unique identifier of the patch to be drawn if no replacement.
* @param replacement Patch replacement string. Will be drawn instead of the
* patch if not @c nullptr.
* @param origin Orient drawing about this offset (topleft:[0,0]).
* @param alignFlags @ref alignmentFlags
* @param patchFlags @ref drawPatchFlags
* @param textFlags @ref drawTextFlags
*/
void WI_DrawPatch(patchid_t patchId,
de::String const &replacement = "",
Expand Down
100 changes: 0 additions & 100 deletions doomsday/plugins/common/src/gl_drawpatch.c

This file was deleted.

0 comments on commit 8c93cf2

Please sign in to comment.