Skip to content

Commit

Permalink
Cleanup|Fixed: Cleaning up merged code
Browse files Browse the repository at this point in the history
Also corrected a problem with RegExpMatch not keeping a reference to the subject string.
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent a1ee27b commit d17f914
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Expand Up @@ -17,7 +17,7 @@ AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: false
BinPackParameters: false
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: true
Expand Down Expand Up @@ -65,7 +65,7 @@ IncludeCategories:
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: false
Expand Down
26 changes: 12 additions & 14 deletions doomsday/apps/client/src/gl/dgl_draw.cpp
Expand Up @@ -80,11 +80,10 @@ struct DGLDrawState
{{0.f, 0.f}, {0.f, 0.f}},
{0.f, 0.f},
0.f};
Vertex primVertices[4];
Vertex primVertices[4];
List<Vertex> vertices;

struct GLData
{
struct GLData {
GLProgram shader;

GLState batchState;
Expand All @@ -111,14 +110,13 @@ struct DGLDrawState
GLUniform uFogRange;
GLUniform uFogColor;

struct DrawBuffer
{
struct DrawBuffer {
GLuint vertexArray = 0;
GLBuffer arrayData;

void release()
{
#if defined (DE_HAVE_VAOS)
#if defined(DE_HAVE_VAOS)
glDeleteVertexArrays(1, &vertexArray);
#endif
arrayData.clear();
Expand Down Expand Up @@ -544,12 +542,12 @@ struct DGLDrawState
LIBGUI_ASSERT_GL_OK();

// Updated pointers.
GL.glVertexAttribPointer(VAA_VERTEX, 3, GL_FLOAT, GL_FALSE, stride, DENG2_OFFSET_PTR(Vertex, vertex));
GL.glVertexAttribPointer(VAA_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, DENG2_OFFSET_PTR(Vertex, color));
GL.glVertexAttribPointer(VAA_TEXCOORD0, 2, GL_FLOAT, GL_FALSE, stride, DENG2_OFFSET_PTR(Vertex, texCoord[0]));
GL.glVertexAttribPointer(VAA_TEXCOORD1, 2, GL_FLOAT, GL_FALSE, stride, DENG2_OFFSET_PTR(Vertex, texCoord[1]));
GL.glVertexAttribPointer(VAA_FRAG_OFFSET, 2, GL_FLOAT, GL_FALSE, stride, DENG2_OFFSET_PTR(Vertex, fragOffset[0]));
GL.glVertexAttribPointer(VAA_BATCH_INDEX, 1, GL_FLOAT, GL_FALSE, stride, DENG2_OFFSET_PTR(Vertex, batchIndex));
glVertexAttribPointer(VAA_VERTEX, 3, GL_FLOAT, GL_FALSE, stride, DENG2_OFFSET_PTR(Vertex, vertex));
glVertexAttribPointer(VAA_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, DENG2_OFFSET_PTR(Vertex, color));
glVertexAttribPointer(VAA_TEXCOORD0, 2, GL_FLOAT, GL_FALSE, stride, DENG2_OFFSET_PTR(Vertex, texCoord[0]));
glVertexAttribPointer(VAA_TEXCOORD1, 2, GL_FLOAT, GL_FALSE, stride, DENG2_OFFSET_PTR(Vertex, texCoord[1]));
glVertexAttribPointer(VAA_FRAG_OFFSET, 2, GL_FLOAT, GL_FALSE, stride, DENG2_OFFSET_PTR(Vertex, fragOffset[0]));
glVertexAttribPointer(VAA_BATCH_INDEX, 1, GL_FLOAT, GL_FALSE, stride, DENG2_OFFSET_PTR(Vertex, batchIndex));
LIBGUI_ASSERT_GL_OK();

glBindBuffer(GL_ARRAY_BUFFER, 0);
Expand Down Expand Up @@ -629,11 +627,11 @@ struct DGLDrawState
{
// We can't draw a line thinner than one pixel.
const float lineWidth = std::max(.5f, GL_state.currentLineWidth);
gl->uFragmentSize = Vector2f(lineWidth, lineWidth) / glState.target().size();
gl->uFragmentSize = Vec2f(lineWidth, lineWidth) / glState.target().size();
}
else
{
gl->uFragmentSize = Vector2f();
gl->uFragmentSize = Vec2f();
}
DGL_FogParams(gl->uFogRange, gl->uFogColor);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/world/base/map.cpp
Expand Up @@ -3209,7 +3209,7 @@ void Map::restoreObjects(Info const &objState, IThinkerMapping const &thinkerMap

if (problemsDetected)
{
LOG_MAP_WARNING("Map objects were not fully restored " DENG2_CHAR_MDASH
LOG_MAP_WARNING("Map objects were not fully restored " DE_CHAR_MDASH
" gameplay may be affected (enable Developer log entries for details)");
}
else
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/plugins/common/include/menu/page.h
Expand Up @@ -81,7 +81,7 @@ class Page
* @param cmdResponder
*/
explicit Page(de::String name,
de::Vec2i const & origin = {},
const de::Vec2i & origin = {},
Flags const & flags = DefaultFlags,
const OnDrawCallback & drawer = {},
const CommandResponder &cmdResponder = {});
Expand Down
Expand Up @@ -53,7 +53,7 @@ class InputBindingWidget : public Widget
void pageActivated() override;

private:
DENG2_PRIVATE(d)
DE_PRIVATE(d)
};

} // namespace menu
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/plugins/common/include/menu/widgets/widget.h
Expand Up @@ -230,9 +230,9 @@ class Widget : public de::Deletable
Widget &setUserValue2(const de::Value &newValue);
const de::Value &userValue2() const;

float scrollingFadeout() const;
float scrollingFadeout(int yTop, int yBottom) const;
de::Vector4f selectionFlashColor(const de::Vector4f &noFlashColor) const;
float scrollingFadeout() const;
float scrollingFadeout(int yTop, int yBottom) const;
de::Vec4f selectionFlashColor(const de::Vec4f &noFlashColor) const;

virtual void pageActivated();

Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/plugins/common/src/hu_menu.cpp
Expand Up @@ -920,7 +920,7 @@ void Hu_MenuInitOptionsPage()
.setShortcut('p')
.setGroup(1)
.setFont(MENU_FONT1)
.setUserValue(String("PlayerSetup"))
.setUserValue(TextValue("PlayerSetup"))
.setAction(Widget::Deactivated, Hu_MenuActionSetActivePage)
.setAction(Widget::FocusGained, Hu_MenuDefaultFocusAction);

Expand Down
Expand Up @@ -1145,7 +1145,7 @@ DE_PIMPL(AutomapWidget)
DGL_Translatef(-(.5f), -(.5f), 0);
#endif

DENG_ASSERT(!std::isnan(view.x));
DE_ASSERT(!std::isnan(view.x));

DGL_Translatef(offsetScale * view.x, -offsetScale * view.y, 1.f);
DGL_Scalef(autopageAspectRatio, autopageAspectRatio, 1.f);
Expand Down Expand Up @@ -1745,7 +1745,7 @@ void AutomapWidget::setCameraAngle(dfloat newAngle)
{
// Already at this target?
newAngle = de::clamp(0.f, newAngle, 359.9999f);
if (newAngle == d->targetAngle) return;
if (fequal(newAngle, d->targetAngle)) return;

// Begin animating toward the new target.
d->oldAngle = d->angle;
Expand Down Expand Up @@ -1800,7 +1800,7 @@ void AutomapWidget::setScale(dfloat newScale)
newScale = de::clamp(d->minScaleMTOF, newScale, d->maxScaleMTOF);

// Already at this target?
if (newScale == d->targetViewScale)
if (fequal(newScale, d->targetViewScale))
return;

// Begin animating toward the new target.
Expand Down Expand Up @@ -1959,7 +1959,7 @@ dfloat AutomapWidget::opacityEX() const
void AutomapWidget::setOpacityEX(dfloat newOpacity)
{
newOpacity = de::clamp(0.f, newOpacity, 1.f);
if (newOpacity != d->targetOpacity)
if (!fequal(newOpacity, d->targetOpacity))
{
// Start animating toward the new target.
d->oldOpacity = d->opacity;
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/plugins/common/src/menu/page.cpp
Expand Up @@ -201,19 +201,19 @@ DE_PIMPL(Page)
if (wi->flags() & Widget::RightColumn)
{
// Move widget to the right side.
wi->geometry().move(Vector2i(leftColumnWidth, 0));
wi->geometry().move(Vec2i(leftColumnWidth, 0));

if (prevWidget && prevWidget->flags() & Widget::LeftColumn)
{
// Align the shorter widget vertically.
if (prevWidget->geometry().height() < wi->geometry().height())
{
prevWidget->geometry().move(Vector2i(
prevWidget->geometry().move(Vec2i(
0, (wi->geometry().height() - prevWidget->geometry().height()) / 2));
}
else
{
wi->geometry().move(Vector2i(
wi->geometry().move(Vec2i(
0, (prevWidget->geometry().height() - wi->geometry().height()) / 2));
}
}
Expand Down
Expand Up @@ -59,7 +59,7 @@ void ButtonWidget::draw() const
Vec4f const &textColor = mnRendState->textColors[color()];
float t = (isFocused()? 1 : 0);

const Vector4f color = selectionFlashColor(textColor);
const Vec4f color = selectionFlashColor(textColor);

// // Flash if focused.
// if (isFocused() && cfg.common.menuTextFlashSpeed > 0)
Expand Down
Expand Up @@ -81,7 +81,7 @@ static void drawSmallText(char const *string, int x, int y, float alpha)
DGL_PopMatrix();
}

DENG2_PIMPL(InputBindingWidget)
DE_PIMPL(InputBindingWidget)
{
bool needGeometry = true; ///< Recalculate geometry based on bindings.
const int maxWidth = SCREENWIDTH * 55 / 100;
Expand All @@ -99,7 +99,7 @@ DENG2_PIMPL(InputBindingWidget)
std::map<bindingitertype_t, std::list<std::tuple<int, std::string, bool>>> bindings;

const controlconfig_t *binds = self().binds;
DENG2_ASSERT(binds != nullptr);
DE_ASSERT(binds != nullptr);

char bindingsBuf[1024];
if (binds->controlName)
Expand Down Expand Up @@ -229,11 +229,11 @@ DENG2_PIMPL(InputBindingWidget)
const auto widgetTopLeft = self().geometry().topLeft;

struct {
bool drawing;
float alpha;
Vector2i widgetTopLeft;
Vector2i origin;
Vector2i size;
bool drawing;
float alpha;
Vec2i widgetTopLeft;
Vec2i origin;
Vec2i size;
} ctx = {drawing,
mnRendState->pageAlpha * self().scrollingFadeout(),
widgetTopLeft,
Expand Down Expand Up @@ -325,7 +325,7 @@ DENG2_PIMPL(InputBindingWidget)
ctx.size = ctx.size.max({ctx.origin.x, ctx.origin.y + lineHeight});
});

return (ctx.size).toVector2ui();
return (ctx.size).toVec2ui();
}
};

Expand Down
Expand Up @@ -66,7 +66,7 @@ void LabelWidget::draw() const

// Vector4f const color = de::lerp(textColor, Vector4f(Vector3f(cfg.common.menuTextFlashColor), textColor.w), t);

const Vector4f color = selectionFlashColor(textColor);
const Vec4f color = selectionFlashColor(textColor);

const float fadeout = scrollingFadeout();
if (fadeout < .001f) return;
Expand Down
16 changes: 8 additions & 8 deletions doomsday/apps/plugins/common/src/menu/widgets/lineeditwidget.cpp
Expand Up @@ -39,8 +39,8 @@ DE_PIMPL_NOREF(LineEditWidget)
String text;
String oldText; ///< For restoring a canceled edit.
String emptyText; ///< Used when value is empty.
int maxLength = 0;
int maxVisibleChars = 0;
dsize maxLength = 0;
int maxVisibleChars = 0;
};

LineEditWidget::LineEditWidget()
Expand Down Expand Up @@ -141,7 +141,7 @@ void LineEditWidget::draw() const
//if(string)
{
// float t = 0;
Vector4f color = Vector4f(Vector3f(cfg.common.menuTextColors[MNDATA_EDIT_TEXT_COLORIDX]), 1.f);
Vec4f color = Vec4f(Vec3f(cfg.common.menuTextColors[MNDATA_EDIT_TEXT_COLORIDX]), 1.f);

// Flash if focused?
if (!isActive()) /* && isFocused() && cfg.common.menuTextFlashSpeed > 0)
Expand All @@ -162,8 +162,8 @@ void LineEditWidget::draw() const
FR_DrawTextXY3(useText, origin.x, origin.y, ALIGN_TOPLEFT, Hu_MenuMergeEffectWithDrawTextFlags(0));

// Are we drawing a cursor?
if(isActive() && isFocused() && (menuTime & 8) &&
(!d->maxLength || d->text.length() < d->maxLength))
if (isActive() && isFocused() && (menuTime & 8) &&
(!d->maxLength || d->text.length() < d->maxLength))
{
origin.x += FR_TextWidth(useText);
FR_DrawCharXY3('_', origin.x, origin.y, ALIGN_TOPLEFT, Hu_MenuMergeEffectWithDrawTextFlags(0));
Expand All @@ -175,15 +175,15 @@ void LineEditWidget::draw() const

int LineEditWidget::maxLength() const
{
return d->maxLength;
return int(d->maxLength);
}

LineEditWidget &LineEditWidget::setMaxLength(int newMaxLength)
{
newMaxLength = de::max(newMaxLength, 0);
if(d->maxLength != newMaxLength)
if (d->maxLength != dsize(newMaxLength))
{
if(newMaxLength < d->maxLength)
if (dsize(newMaxLength) < d->maxLength)
{
d->text.truncate(CharPos(newMaxLength));
d->oldText.truncate(CharPos(newMaxLength));
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/plugins/common/src/menu/widgets/listwidget.cpp
Expand Up @@ -126,7 +126,7 @@ void ListWidget::draw() const
Vec4f const &textColor = mnRendState->textColors[color()];
float t = flashSelection? 1 : 0;

Vector4f flashColor = textColor;
Vec4f flashColor = textColor;

if (flashSelection) /* && cfg.common.menuTextFlashSpeed > 0)
{
Expand Down Expand Up @@ -322,7 +322,7 @@ bool ListWidget::selectItemByValue(int userValue, int flags)

bool ListWidget::reorder(int itemIndex, int indexOffset)
{
if (itemIndex + indexOffset < 0 || itemIndex + indexOffset >= d->items.size())
if (itemIndex + indexOffset < 0 || itemIndex + indexOffset >= d->items.sizei())
{
return false; // Would go out of bounds.
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/plugins/common/src/menu/widgets/widget.cpp
Expand Up @@ -333,13 +333,13 @@ float Widget::scrollingFadeout(int yTop, int yBottom) const
return 1.f;
}

Vector4f Widget::selectionFlashColor(const Vector4f &noFlashColor) const
Vec4f Widget::selectionFlashColor(const Vec4f &noFlashColor) const
{
if (isFocused() && cfg.common.menuTextFlashSpeed > 0)
{
const float speed = cfg.common.menuTextFlashSpeed / 2.f;
const float t = (1 + sin(page().timer() / (float)TICSPERSEC * speed * DD_PI)) / 2;
return lerp(noFlashColor, Vector4f(Vector3f(cfg.common.menuTextFlashColor), 1.f), t);
return lerp(noFlashColor, Vec4f(Vec3f(cfg.common.menuTextFlashColor), 1.f), t);
}
return noFlashColor;
}
Expand Down
8 changes: 3 additions & 5 deletions doomsday/libs/appfw/src/widgets/panelwidget.cpp
@@ -1,5 +1,3 @@
#include <utility>

/** @file panelwidget.cpp
*
* @authors Copyright (c) 2013-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
Expand Down Expand Up @@ -31,9 +29,9 @@

namespace de {

constexpr double OPENING_ANIM_SPAN = 0.3;
constexpr double OPENING_ANIM_SPAN_EASED_OUT = 0.18;
constexpr double CLOSING_ANIM_SPAN = 0.22;
static constexpr double OPENING_ANIM_SPAN = 0.3;
static constexpr double OPENING_ANIM_SPAN_EASED_OUT = 0.18;
static constexpr double CLOSING_ANIM_SPAN = 0.22;

DE_GUI_PIMPL(PanelWidget)
, DE_OBSERVES(Asset, StateChange)
Expand Down
3 changes: 2 additions & 1 deletion doomsday/libs/core/include/de/data/regexp.h
Expand Up @@ -28,7 +28,8 @@ namespace de {
class DE_PUBLIC RegExpMatch
{
public:
iRegExpMatch match;
iRegExpMatch match; ///< Match results.
String subject; // ensures a persistent copy exists

RegExpMatch();

Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/core/src/data/record.cpp
Expand Up @@ -1042,7 +1042,7 @@ String Record::asText(String const &prefix, List *lines) const
int numberOfLines = subContent.count('\n');
if (numberOfLines > SUBRECORD_CONTENT_EXCERPT_THRESHOLD)
{
subContent = String("(%i lines)", numberOfLines);
subContent = Stringf("(%i lines)", numberOfLines);
}

KeyValue kv(prefix + i->first + separator, subContent);
Expand Down

0 comments on commit d17f914

Please sign in to comment.