Skip to content

Commit

Permalink
Make the source unity build-friendly
Browse files Browse the repository at this point in the history
Avoid name collisions of static globals and add a missing header guard.

This is enough to build all sources used by Unvanquished concatenated,
except SystemInterface.cpp
  • Loading branch information
slipher committed Nov 20, 2024
1 parent 29735f6 commit 44b3095
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Include/RmlUi/Core/StyleSheetSpecification.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class RMLUICORE_API StyleSheetSpecification
PropertySpecification properties;

UniquePtr<DefaultStyleSheetParsers> default_parsers;

static StyleSheetSpecification* instance; // singleton
};

} // namespace Rml
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Elements/WidgetSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

namespace Rml {

static const float DEFAULT_REPEAT_DELAY = 0.5f;
static const float DEFAULT_REPEAT_PERIOD = 0.1f;
static const float SLIDER_ARROW_REPEAT_DELAY = 0.5f;
static const float SLIDER_ARROW_REPEAT_PERIOD = 0.1f;

WidgetSlider::WidgetSlider(ElementFormControl* _parent)
{
Expand Down Expand Up @@ -156,7 +156,7 @@ void WidgetSlider::Update()
arrow_timers[i] -= delta_time;
while (arrow_timers[i] <= 0)
{
arrow_timers[i] += DEFAULT_REPEAT_PERIOD;
arrow_timers[i] += SLIDER_ARROW_REPEAT_PERIOD;
SetBarPosition(i == 0 ? OnLineDecrement() : OnLineIncrement());
}
}
Expand Down Expand Up @@ -390,13 +390,13 @@ void WidgetSlider::ProcessEvent(Event& event)
}
else if (event.GetTargetElement() == arrows[0])
{
arrow_timers[0] = DEFAULT_REPEAT_DELAY;
arrow_timers[0] = SLIDER_ARROW_REPEAT_DELAY;
last_update_time = Clock::GetElapsedTime();
SetBarPosition(OnLineDecrement());
}
else if (event.GetTargetElement() == arrows[1])
{
arrow_timers[1] = DEFAULT_REPEAT_DELAY;
arrow_timers[1] = SLIDER_ARROW_REPEAT_DELAY;
last_update_time = Clock::GetElapsedTime();
SetBarPosition(OnLineIncrement());
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/StyleSheetFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

namespace Rml {

static UniquePtr<StyleSheetFactory> instance;
UniquePtr<StyleSheetFactory> StyleSheetFactory::instance;

StyleSheetFactory::StyleSheetFactory() :
selectors{
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/StyleSheetFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class StyleSheetFactory {
// Custom complex selectors available for style sheets.
using SelectorMap = UnorderedMap<String, StructuralSelectorType>;
SelectorMap selectors;

static UniquePtr<StyleSheetFactory> instance; // singleton
};

} // namespace Rml
Expand Down
7 changes: 1 addition & 6 deletions Source/Core/StyleSheetNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@

namespace Rml {

static inline bool IsTextElement(const Element* element)
{
return element->GetTagName() == "#text";
}

StyleSheetNode::StyleSheetNode()
{
CalculateAndSetSpecificity();
Expand Down Expand Up @@ -329,7 +324,7 @@ bool StyleSheetNode::TraverseMatch(const Element* element) const
{
// First check if our sibling is a text element and if so skip it. For the descendant/child combinator above we can omit this step since
// text elements don't have children and thus any ancestor is not a text element.
if (IsTextElement(element))
if (element->GetTagName() == "#text")
continue;
else if (parent->Match(element) && parent->TraverseMatch(element))
return true;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/StyleSheetSpecification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

namespace Rml {

static StyleSheetSpecification* instance = nullptr;
StyleSheetSpecification* StyleSheetSpecification::instance = nullptr;


struct DefaultStyleSheetParsers {
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/WidgetScroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

namespace Rml {

static const float DEFAULT_REPEAT_DELAY = 0.5f;
static const float DEFAULT_REPEAT_PERIOD = 0.1f;
static const float SCROLL_ARROW_REPEAT_DELAY = 0.5f;
static const float SCROLL_ARROW_REPEAT_PERIOD = 0.1f;

WidgetScroll::WidgetScroll(Element* _parent)
{
Expand Down Expand Up @@ -160,7 +160,7 @@ void WidgetScroll::Update()
arrow_timers[i] -= delta_time;
while (arrow_timers[i] <= 0)
{
arrow_timers[i] += DEFAULT_REPEAT_PERIOD;
arrow_timers[i] += SCROLL_ARROW_REPEAT_PERIOD;
SetBarPosition(i == 0 ? OnLineDecrement() : OnLineIncrement());
}
}
Expand Down Expand Up @@ -432,13 +432,13 @@ void WidgetScroll::ProcessEvent(Event& event)
{
if (event.GetTargetElement() == arrows[0])
{
arrow_timers[0] = DEFAULT_REPEAT_DELAY;
arrow_timers[0] = SCROLL_ARROW_REPEAT_DELAY;
last_update_time = Clock::GetElapsedTime();
SetBarPosition(OnLineDecrement());
}
else if (event.GetTargetElement() == arrows[1])
{
arrow_timers[1] = DEFAULT_REPEAT_DELAY;
arrow_timers[1] = SCROLL_ARROW_REPEAT_DELAY;
last_update_time = Clock::GetElapsedTime();
SetBarPosition(OnLineIncrement());
}
Expand Down
5 changes: 5 additions & 0 deletions Source/Debugger/CommonSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
*
*/

#ifndef RMLUI_DEBUGGER_COMMONSOURCE_H
#define RMLUI_DEBUGGER_COMMONSOURCE_H

static const char* common_rcss = R"RCSS(
body
{
Expand Down Expand Up @@ -195,3 +198,5 @@ handle#size_handle
background-color: #888;
}
)RCSS";

#endif

0 comments on commit 44b3095

Please sign in to comment.