Updated various functions in ui::Atoms

This commit is contained in:
Walter Julius Hennecke 2019-10-19 15:05:29 +02:00
parent f0d2108b9d
commit 268b4b0942
13 changed files with 9048 additions and 9640 deletions

View file

@ -28,6 +28,12 @@ public:
b_{detail::color_check_bounds(_b)}, a_{detail::color_check_bounds(_a)} {
}
constexpr Color(const Color &) = default;
constexpr Color(Color &&) = default;
constexpr Color &operator=(const Color &) = default;
constexpr Color &operator=(Color &&) = default;
constexpr Color(vec4_t v) noexcept : r_{v[0]}, g_{v[1]}, b_{v[2]}, a_{v[3]} {}
union {

View file

@ -8,105 +8,105 @@ static_assert(common::Rectangle<int>().left == 0);
static_assert(common::Rectangle<int>(1).left == 1);
static_assert(common::Rectangle<int>(1).top == 0);
static_assert(common::Rectangle<int>(1).right == 0);
static_assert(common::Rectangle<int>(1).right == 1);
static_assert(common::Rectangle<int>(1).bottom == 0);
static_assert(common::Rectangle<int>(1, -4).left == 1);
static_assert(common::Rectangle<int>(1, -4).top == -4);
static_assert(common::Rectangle<int>(1, -4).right == 0);
static_assert(common::Rectangle<int>(1, -4).bottom == 0);
static_assert(common::Rectangle<int>(1, -4).right == 1);
static_assert(common::Rectangle<int>(1, -4).bottom == -4);
static_assert(common::Rectangle<int>(1, -4, 564).left == 1);
static_assert(common::Rectangle<int>(1, -4, 564).top == -4);
static_assert(common::Rectangle<int>(1, -4, 564).right == 564);
static_assert(common::Rectangle<int>(1, -4, 564).bottom == 0);
static_assert(common::Rectangle<int>(1, -4, 563).left == 1);
static_assert(common::Rectangle<int>(1, -4, 563).top == -4);
static_assert(common::Rectangle<int>(1, -4, 563).right == 564);
static_assert(common::Rectangle<int>(1, -4, 563).bottom == -4);
static_assert(common::Rectangle<int>(1, -4, 564, 45).left == 1);
static_assert(common::Rectangle<int>(1, -4, 564, 45).top == -4);
static_assert(common::Rectangle<int>(1, -4, 564, 45).right == 564);
static_assert(common::Rectangle<int>(1, -4, 564, 45).bottom == 45);
static_assert(common::Rectangle<int>(1, -4, 563, 49).left == 1);
static_assert(common::Rectangle<int>(1, -4, 563, 49).top == -4);
static_assert(common::Rectangle<int>(1, -4, 563, 49).right == 564);
static_assert(common::Rectangle<int>(1, -4, 563, 49).bottom == 45);
static_assert(common::Rectangle<int>(1.0, -4.3, 23.4f, 45).left == 1);
static_assert(common::Rectangle<int>(1.0, -4.3, 23.4f, 45).top == -4);
static_assert(common::Rectangle<int>(1.0, -4.3, 23.4f, 45).right == 23);
static_assert(common::Rectangle<int>(1.0, -4.3, 23.4f, 45).bottom == 45);
static_assert(common::Rectangle<int>(1.0, -4.3, 22.4f, 49.3).left == 1);
static_assert(common::Rectangle<int>(1.0, -4.3, 22.4f, 49.3).top == -4);
static_assert(common::Rectangle<int>(1.0, -4.3, 22.4f, 49.3).right == 23);
static_assert(common::Rectangle<int>(1.0, -4.3, 22.4f, 49.3).bottom == 45);
static_assert(common::Rectangle<int>(0, 0, 1, 1).width() == 1);
static_assert(common::Rectangle<int>(0, 0, 1, 1).height() == 1);
static_assert(common::Rectangle<int>(0, 0, 1, 1).area() == 1);
static_assert(common::Rectangle<int>(4, 4, 10, 10).width() == 6);
static_assert(common::Rectangle<int>(4, 4, 10, 10).height() == 6);
static_assert(common::Rectangle<int>(4, 4, 10, 10).area() == 36);
static_assert(common::Rectangle<int>(4, 4, 10, 10).width() == 10);
static_assert(common::Rectangle<int>(4, 4, 10, 10).height() == 10);
static_assert(common::Rectangle<int>(4, 4, 10, 10).area() == 100);
static_assert(common::Rectangle<int>(1, 2, 3, 4) ==
common::Rectangle<int>(1, 2, 3, 4));
static_assert(common::Rectangle<int>(1, 2, 3, 4) !=
common::Rectangle<int>(4, 3, 2, 1));
static_assert(common::bounds(common::Rectangle<int>{3, 6, 7, 10},
common::Rectangle<int>{4, 7, 6, 9})
static_assert(common::bounds(common::Rectangle<int>{3, 6, 4, 4},
common::Rectangle<int>{4, 7, 2, 2})
.left == 3);
static_assert(common::bounds(common::Rectangle<int>{3, 6, 7, 10},
common::Rectangle<int>{4, 7, 6, 9})
static_assert(common::bounds(common::Rectangle<int>{3, 6, 4, 4},
common::Rectangle<int>{4, 7, 2, 2})
.top == 6);
static_assert(common::bounds(common::Rectangle<int>{3, 6, 7, 10},
common::Rectangle<int>{4, 7, 6, 9})
static_assert(common::bounds(common::Rectangle<int>{3, 6, 4, 4},
common::Rectangle<int>{4, 7, 2, 2})
.right == 7);
static_assert(common::bounds(common::Rectangle<int>{3, 6, 7, 10},
common::Rectangle<int>{4, 7, 6, 9})
static_assert(common::bounds(common::Rectangle<int>{3, 6, 4, 4},
common::Rectangle<int>{4, 7, 2, 2})
.bottom == 10);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{4, 3, 6, 5})
static_assert(common::bounds(common::Rectangle<int>{1, 1, 2, 2},
common::Rectangle<int>{4, 3, 2, 2})
.left == 1);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{4, 3, 6, 5})
static_assert(common::bounds(common::Rectangle<int>{1, 1, 2, 2},
common::Rectangle<int>{4, 3, 2, 2})
.top == 1);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{4, 3, 6, 5})
static_assert(common::bounds(common::Rectangle<int>{1, 1, 2, 2},
common::Rectangle<int>{4, 3, 2, 2})
.right == 6);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{4, 3, 6, 5})
static_assert(common::bounds(common::Rectangle<int>{1, 1, 2, 2},
common::Rectangle<int>{4, 3, 2, 2})
.bottom == 5);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{2, 2, 5, 4})
static_assert(common::bounds(common::Rectangle<int>{1, 1, 2, 2},
common::Rectangle<int>{2, 2, 3, 2})
.left == 1);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{2, 2, 5, 4})
static_assert(common::bounds(common::Rectangle<int>{1, 1, 2, 2},
common::Rectangle<int>{2, 2, 3, 2})
.top == 1);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{2, 2, 5, 4})
static_assert(common::bounds(common::Rectangle<int>{1, 1, 2, 2},
common::Rectangle<int>{2, 2, 3, 2})
.right == 5);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{2, 2, 5, 4})
static_assert(common::bounds(common::Rectangle<int>{1, 1, 2, 2},
common::Rectangle<int>{2, 2, 3, 2})
.bottom == 4);
static_assert(common::bounds(common::Rectangle<int>{2, 2, 5, 4},
common::Rectangle<int>{4, 3, 6, 5})
static_assert(common::bounds(common::Rectangle<int>{2, 2, 3, 2},
common::Rectangle<int>{4, 3, 2, 2})
.left == 2);
static_assert(common::bounds(common::Rectangle<int>{2, 2, 5, 4},
common::Rectangle<int>{4, 3, 6, 5})
static_assert(common::bounds(common::Rectangle<int>{2, 2, 3, 2},
common::Rectangle<int>{4, 3, 2, 2})
.top == 2);
static_assert(common::bounds(common::Rectangle<int>{2, 2, 5, 4},
common::Rectangle<int>{4, 3, 6, 5})
static_assert(common::bounds(common::Rectangle<int>{2, 2, 3, 2},
common::Rectangle<int>{4, 3, 2, 2})
.right == 6);
static_assert(common::bounds(common::Rectangle<int>{2, 2, 5, 4},
common::Rectangle<int>{4, 3, 6, 5})
static_assert(common::bounds(common::Rectangle<int>{2, 2, 3, 2},
common::Rectangle<int>{4, 3, 2, 2})
.bottom == 5);
static_assert(common::bounds(common::Rectangle<int>{3, 6, 7, 10},
common::Rectangle<int>{3, 6, 7, 10})
static_assert(common::bounds(common::Rectangle<int>{3, 6, 4, 4},
common::Rectangle<int>{3, 6, 4, 4})
.left == 3);
static_assert(common::bounds(common::Rectangle<int>{3, 6, 7, 10},
common::Rectangle<int>{3, 6, 7, 10})
static_assert(common::bounds(common::Rectangle<int>{3, 6, 4, 4},
common::Rectangle<int>{3, 6, 4, 4})
.top == 6);
static_assert(common::bounds(common::Rectangle<int>{3, 6, 7, 10},
common::Rectangle<int>{3, 6, 7, 10})
static_assert(common::bounds(common::Rectangle<int>{3, 6, 4, 4},
common::Rectangle<int>{3, 6, 4, 4})
.right == 7);
static_assert(common::bounds(common::Rectangle<int>{3, 6, 7, 10},
common::Rectangle<int>{3, 6, 7, 10})
static_assert(common::bounds(common::Rectangle<int>{3, 6, 4, 4},
common::Rectangle<int>{3, 6, 4, 4})
.bottom == 10);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
@ -119,15 +119,15 @@ static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{2, 2, 5, 4},
common::Rectangle<int>{3, 6, 7, 10})
.top == 1);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{4, 3, 6, 5},
common::Rectangle<int>{2, 2, 5, 4},
common::Rectangle<int>{3, 6, 7, 10})
static_assert(common::bounds(common::Rectangle<int>{1, 1, 2, 2},
common::Rectangle<int>{4, 3, 2, 2},
common::Rectangle<int>{2, 2, 3, 2},
common::Rectangle<int>{3, 6, 4, 4})
.right == 7);
static_assert(common::bounds(common::Rectangle<int>{1, 1, 3, 3},
common::Rectangle<int>{4, 3, 6, 5},
common::Rectangle<int>{2, 2, 5, 4},
common::Rectangle<int>{3, 6, 7, 10})
static_assert(common::bounds(common::Rectangle<int>{1, 1, 2, 2},
common::Rectangle<int>{4, 3, 2, 2},
common::Rectangle<int>{2, 2, 3, 2},
common::Rectangle<int>{3, 6, 4, 4})
.bottom == 10);
TEST_CASE("rectangle_construct", "[common::Rectangle]") {
@ -138,43 +138,43 @@ TEST_CASE("rectangle_construct", "[common::Rectangle]") {
REQUIRE(common::Rectangle<int>(1).left == 1);
REQUIRE(common::Rectangle<int>(1).top == 0);
REQUIRE(common::Rectangle<int>(1).right == 0);
REQUIRE(common::Rectangle<int>(1).right == 1);
REQUIRE(common::Rectangle<int>(1).bottom == 0);
REQUIRE(common::Rectangle<int>(1, -4).left == 1);
REQUIRE(common::Rectangle<int>(1, -4).top == -4);
REQUIRE(common::Rectangle<int>(1, -4).right == 0);
REQUIRE(common::Rectangle<int>(1, -4).bottom == 0);
REQUIRE(common::Rectangle<int>(1, -4).right == 1);
REQUIRE(common::Rectangle<int>(1, -4).bottom == -4);
REQUIRE(common::Rectangle<int>(1, -4, 564).left == 1);
REQUIRE(common::Rectangle<int>(1, -4, 564).top == -4);
REQUIRE(common::Rectangle<int>(1, -4, 564).right == 564);
REQUIRE(common::Rectangle<int>(1, -4, 564).bottom == 0);
REQUIRE(common::Rectangle<int>(1, -4, 563).left == 1);
REQUIRE(common::Rectangle<int>(1, -4, 563).top == -4);
REQUIRE(common::Rectangle<int>(1, -4, 563).right == 564);
REQUIRE(common::Rectangle<int>(1, -4, 563).bottom == -4);
REQUIRE(common::Rectangle<int>(1, -4, 564, 45).left == 1);
REQUIRE(common::Rectangle<int>(1, -4, 564, 45).top == -4);
REQUIRE(common::Rectangle<int>(1, -4, 564, 45).right == 564);
REQUIRE(common::Rectangle<int>(1, -4, 564, 45).bottom == 45);
REQUIRE(common::Rectangle<int>(1, -4, 563, 49).left == 1);
REQUIRE(common::Rectangle<int>(1, -4, 563, 49).top == -4);
REQUIRE(common::Rectangle<int>(1, -4, 563, 49).right == 564);
REQUIRE(common::Rectangle<int>(1, -4, 563, 49).bottom == 45);
REQUIRE(common::Rectangle<int>(1.0, -4.3, 23.4f, 45).left == 1);
REQUIRE(common::Rectangle<int>(1.0, -4.3, 23.4f, 45).top == -4);
REQUIRE(common::Rectangle<int>(1.0, -4.3, 23.4f, 45).right == 23);
REQUIRE(common::Rectangle<int>(1.0, -4.3, 23.4f, 45).bottom == 45);
REQUIRE(common::Rectangle<int>(1.0, -4.3, 22.4f, 49.3).left == 1);
REQUIRE(common::Rectangle<int>(1.0, -4.3, 22.4f, 49.3).top == -4);
REQUIRE(common::Rectangle<int>(1.0, -4.3, 22.4f, 49.3).right == 23);
REQUIRE(common::Rectangle<int>(1.0, -4.3, 22.4f, 49.3).bottom == 45);
}
TEST_CASE("rectangle_width", "[common::Rectangle]") {
REQUIRE(common::Rectangle<int>(0, 0, 1, 1).width() == 1);
REQUIRE(common::Rectangle<int>(4, 4, 10, 10).width() == 6);
REQUIRE(common::Rectangle<int>(4, 4, 6, 6).width() == 6);
}
TEST_CASE("rectangle_height", "[common::Rectangle]") {
REQUIRE(common::Rectangle<int>(0, 0, 1, 1).height() == 1);
REQUIRE(common::Rectangle<int>(4, 4, 10, 10).height() == 6);
REQUIRE(common::Rectangle<int>(4, 4, 6, 6).height() == 6);
}
TEST_CASE("reactangle_area", "[common::Rectangle]") {
REQUIRE(common::Rectangle<int>(0, 0, 1, 1).area() == 1);
REQUIRE(common::Rectangle<int>(4, 4, 10, 10).area() == 36);
REQUIRE(common::Rectangle<int>(4, 4, 6, 6).area() == 36);
}
TEST_CASE("rectangle_equality", "[common::Rectangle]") {
@ -185,9 +185,9 @@ TEST_CASE("rectangle_equality", "[common::Rectangle]") {
}
TEST_CASE("rectangle_intersect", "[common::Rectangle]") {
auto rect_a = common::Rectangle<int>{1, 1, 3, 3};
auto rect_b = common::Rectangle<int>{4, 3, 6, 5};
auto rect_c = common::Rectangle<int>{2, 2, 5, 4};
auto rect_a = common::Rectangle<int>{1, 1, 2, 2};
auto rect_b = common::Rectangle<int>{4, 3, 2, 2};
auto rect_c = common::Rectangle<int>{2, 2, 3, 2};
REQUIRE(!common::intersect(rect_a, rect_b));
REQUIRE(common::intersect(rect_a, rect_a));
@ -196,16 +196,16 @@ TEST_CASE("rectangle_intersect", "[common::Rectangle]") {
REQUIRE(common::intersect(rect_c, rect_a));
REQUIRE(common::intersect(rect_c, rect_b));
auto rect_d = common::Rectangle<int>{3, 6, 7, 10};
auto rect_e = common::Rectangle<int>{4, 7, 6, 9};
auto rect_d = common::Rectangle<int>{3, 6, 4, 4};
auto rect_e = common::Rectangle<int>{4, 7, 2, 2};
REQUIRE(common::intersect(rect_d, rect_e));
REQUIRE(common::intersect(rect_e, rect_d));
}
TEST_CASE("rectangle_intersection", "[common::Rectangle]") {
auto rect_d = common::Rectangle<int>{3, 6, 7, 10};
auto rect_e = common::Rectangle<int>{4, 7, 6, 9};
auto rect_d = common::Rectangle<int>{3, 6, 4, 4};
auto rect_e = common::Rectangle<int>{4, 7, 2, 2};
auto intersectopn_d_e = common::intersection(rect_d, rect_e);
REQUIRE(intersectopn_d_e);
@ -221,9 +221,9 @@ TEST_CASE("rectangle_intersection", "[common::Rectangle]") {
REQUIRE(intersection_e_d->right == rect_e.right);
REQUIRE(intersection_e_d->bottom == rect_e.bottom);
auto rect_a = common::Rectangle<int>{1, 1, 3, 3};
auto rect_b = common::Rectangle<int>{4, 3, 6, 5};
auto rect_c = common::Rectangle<int>{2, 2, 5, 4};
auto rect_a = common::Rectangle<int>{1, 1, 2, 2};
auto rect_b = common::Rectangle<int>{4, 3, 2, 2};
auto rect_c = common::Rectangle<int>{2, 2, 3, 2};
auto intersection_a_b = common::intersection(rect_a, rect_b);
REQUIRE(!intersection_a_b);
@ -253,8 +253,8 @@ TEST_CASE("rectangle_intersection", "[common::Rectangle]") {
}
TEST_CASE("rectangle_bounds", "[common::Rectangle]") {
auto rect_d = common::Rectangle<int>{3, 6, 7, 10};
auto rect_e = common::Rectangle<int>{4, 7, 6, 9};
auto rect_d = common::Rectangle<int>{3, 6, 4, 4};
auto rect_e = common::Rectangle<int>{4, 7, 2, 2};
auto bounds_d_e = common::bounds(rect_d, rect_e);
REQUIRE(bounds_d_e.top == rect_d.top);
@ -262,9 +262,9 @@ TEST_CASE("rectangle_bounds", "[common::Rectangle]") {
REQUIRE(bounds_d_e.bottom == rect_d.bottom);
REQUIRE(bounds_d_e.right == rect_d.right);
auto rect_a = common::Rectangle<int>{1, 1, 3, 3};
auto rect_b = common::Rectangle<int>{4, 3, 6, 5};
auto rect_c = common::Rectangle<int>{2, 2, 5, 4};
auto rect_a = common::Rectangle<int>{1, 1, 2, 2};
auto rect_b = common::Rectangle<int>{4, 3, 2, 2};
auto rect_c = common::Rectangle<int>{2, 2, 3, 2};
auto bounds_a_b = common::bounds(rect_a, rect_b);
REQUIRE(bounds_a_b.left == rect_a.left);

View file

@ -16,13 +16,20 @@ public:
typename = std::enable_if_t<
std::is_convertible_v<A, T> && std::is_convertible_v<B, T> &&
std::is_convertible_v<C, T> && std::is_convertible_v<D, T>>>
constexpr explicit Rectangle(A _left, B _top = 0, C _right = 0, D _bottom = 0)
constexpr Rectangle(A _left, B _top = 0, C _width = 0, D _height = 0)
: left{static_cast<T>(_left)}, top{static_cast<T>(_top)},
right{static_cast<T>(_right)}, bottom{static_cast<T>(_bottom)} {}
right{static_cast<T>(_left + _width)}, bottom{static_cast<T>(
_top + _height)} {}
constexpr T width() const { return right - left; }
constexpr T height() const { return bottom - top; }
constexpr T area() const { return width() * height(); }
[[nodiscard]] constexpr T width() const { return right - left; }
[[nodiscard]] constexpr T height() const { return bottom - top; }
[[nodiscard]] constexpr T area() const { return width() * height(); }
Rectangle(const Rectangle &) = default;
Rectangle(Rectangle &&) noexcept = default;
Rectangle &operator=(const Rectangle &) = default;
Rectangle &operator=(Rectangle &&) noexcept = default;
constexpr bool operator==(const Rectangle &rhs) const {
return std::tie(left, top, right, bottom) ==
@ -56,7 +63,7 @@ std::optional<Rectangle<ResultType>> intersection(const Rectangle<A> &a,
auto right = std::min(a.right, b.right);
auto top = std::max(a.top, b.top);
return Rectangle<ResultType>(left, top, right, bottom);
return Rectangle<ResultType>(left, top, right - left, bottom - top);
}
template <typename A, typename... Args>
@ -64,8 +71,8 @@ constexpr Rectangle<A> bounds(const Rectangle<A> &a, Args &&... args) {
if constexpr (sizeof...(args) > 0) {
auto b = bounds(std::forward<Args>(args)...);
return Rectangle<A>{std::min(a.left, b.left), std::min(a.top, b.top),
std::max(a.right, b.right),
std::max(a.bottom, b.bottom)};
std::max(a.right, b.right) - std::min(a.left, b.left),
std::max(a.bottom, b.bottom) - std::min(a.top, b.top)};
}
return a;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -8,261 +8,228 @@ CONFIRMATION MENU
=======================================================================
*/
#include <utility>
#include "Atoms.h"
#include "ui_local.h"
#include "ui_logger.h"
#include <common/ColorTable.h>
enum ui_confirmIDs_e {
ID_CONFIRM_NO = 10,
ID_CONFIRM_YES
};
using namespace common;
using namespace ui;
enum ui_confirmIDs_e { ID_CONFIRM_NO = 10, ID_CONFIRM_YES };
typedef struct
{
menuframework_s menu;
typedef struct {
menuframework_s menu_{};
menubitmap_s no;
menubitmap_s yes;
menubitmap_s no_{};
menubitmap_s yes_{};
/*const*/ char * question;
void(*draw)(void);
void(*action)(qboolean result);
qhandle_t cornerPic;
std::string question_;
std::function<void()> draw_;
std::function<void(bool result)> action_;
qhandle_t corner_pic_{0};
} confirmMenu_t;
static confirmMenu_t s_confirm;
static confirmMenu_t s_confirm;
/*
=================
ConfirmMenu_Event
=================
*/
static void ConfirmMenu_Event(void* ptr, int32_t event)
{
UI_LogFuncBegin();
qboolean result;
static void ConfirmMenu_Event(void *ptr, int32_t event) {
qboolean result;
if (event != QM_ACTIVATED)
{
UI_LogFuncEnd();
return;
}
if (event != QM_ACTIVATED) {
return;
}
UI_PopMenu();
UI_PopMenu();
if (((menucommon_s*)ptr)->id == ID_CONFIRM_NO)
{
result = qfalse;
}
else
{
result = qtrue;
}
if (((menucommon_s *)ptr)->id == ID_CONFIRM_NO) {
result = qfalse;
} else {
result = qtrue;
}
if (s_confirm.action)
{
s_confirm.action(result);
}
UI_LogFuncEnd();
if (s_confirm.action_) {
s_confirm.action_(result);
}
}
/*
=================
ConfirmMenu_Key
=================
*/
static sfxHandle_t ConfirmMenu_Key(int32_t key)
{
UI_LogFuncBegin();
switch (key)
{
case K_KP_LEFTARROW:
case K_LEFTARROW:
case K_KP_RIGHTARROW:
case K_RIGHTARROW:
key = K_TAB;
break;
static sfxHandle_t ConfirmMenu_Key(int32_t key) {
switch (key) {
case K_KP_LEFTARROW:
case K_LEFTARROW:
case K_KP_RIGHTARROW:
case K_RIGHTARROW:
key = K_TAB;
break;
case 'n':
case 'N':
ConfirmMenu_Event(&s_confirm.no, QM_ACTIVATED);
break;
case 'n':
case 'N':
ConfirmMenu_Event(&s_confirm.no_, QM_ACTIVATED);
break;
case 'y':
case 'Y':
ConfirmMenu_Event(&s_confirm.yes, QM_ACTIVATED);
break;
}
case 'y':
case 'Y':
ConfirmMenu_Event(&s_confirm.yes_, QM_ACTIVATED);
break;
}
UI_LogFuncEnd();
return Menu_DefaultKey(&s_confirm.menu, key);
return Menu_DefaultKey(&s_confirm.menu_, key);
}
/*
=================
ConfirmMenu_Draw
=================
*/
static void ConfirmMenu_Draw(void)
{
UI_LogFuncBegin();
UI_MenuFrame(&s_confirm.menu);
static void ConfirmMenu_Draw() {
UI_MenuFrame(&s_confirm.menu_);
// End of upper line
trap_R_SetColor(colorTable[CT_LTBROWN1]);
UI_DrawHandlePic(482, 136, MENU_BUTTON_MED_WIDTH - 22, MENU_BUTTON_MED_HEIGHT, uis.whiteShader);
UI_DrawHandlePic(460 + MENU_BUTTON_MED_WIDTH - 6, 136, -19, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd); //right
// End of upper line
trap_R_SetColor(colorTable[CT_LTBROWN1]);
Atoms::DrawHandlePic(
{482, 136, MENU_BUTTON_MED_WIDTH - 22, MENU_BUTTON_MED_HEIGHT},
uis.whiteShader);
Atoms::DrawHandlePic(
{460 + MENU_BUTTON_MED_WIDTH - 6, 136, -19, MENU_BUTTON_MED_HEIGHT},
uis.graphicButtonLeftEnd); // right
trap_R_SetColor(colorTable[CT_DKBLUE2]);
UI_DrawHandlePic(30, 203, 47, 186, uis.whiteShader); // Left hand column
trap_R_SetColor(colorTable[CT_DKBLUE2]);
Atoms::DrawHandlePic({30, 203, 47, 186}, uis.whiteShader); // Left hand column
UI_DrawProportionalString(74, 66, "286", UI_RIGHT | UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(74, 84, "386", UI_RIGHT | UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(74, 188, "486", UI_RIGHT | UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(74, 207, "8088", UI_RIGHT | UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(74, 395, "12799", UI_RIGHT | UI_TINYFONT, colorTable[CT_BLACK]);
Atoms::DrawProportionalString({74, 66}, "286", UI_RIGHT | UI_TINYFONT,
ColorTable[CT_BLACK]);
Atoms::DrawProportionalString({74, 84}, "386", UI_RIGHT | UI_TINYFONT,
ColorTable[CT_BLACK]);
Atoms::DrawProportionalString({74, 188}, "486", UI_RIGHT | UI_TINYFONT,
ColorTable[CT_BLACK]);
Atoms::DrawProportionalString({74, 207}, "8088", UI_RIGHT | UI_TINYFONT,
ColorTable[CT_BLACK]);
Atoms::DrawProportionalString({74, 395}, "12799", UI_RIGHT | UI_TINYFONT,
ColorTable[CT_BLACK]);
trap_R_SetColor(colorTable[CT_LTBLUE1]);
Atoms::DrawHandlePic({132, 142, 128, -64},
s_confirm.corner_pic_); // Top Left corner
Atoms::DrawHandlePic({132, 352, 128, 64},
s_confirm.corner_pic_); // Bottom Left corner
trap_R_SetColor(colorTable[CT_LTBLUE1]);
UI_DrawHandlePic(132, 142, 128, -64, s_confirm.cornerPic); // Top Left corner
UI_DrawHandlePic(132, 352, 128, 64, s_confirm.cornerPic); // Bottom Left corner
Atoms::DrawHandlePic({429, 142, -128, -64},
s_confirm.corner_pic_); // Top Right corner
Atoms::DrawHandlePic({429, 352, -128, 64},
s_confirm.corner_pic_); // Bottom Right corner
UI_DrawHandlePic(429, 142, -128, -64, s_confirm.cornerPic); // Top Right corner
UI_DrawHandlePic(429, 352, -128, 64, s_confirm.cornerPic); // Bottom Right corner
Atoms::DrawHandlePic({145, 175, 395, 18}, uis.whiteShader); // Top
Atoms::DrawHandlePic({132, 193, 47, 175}, uis.whiteShader); // Left side
Atoms::DrawHandlePic({510, 193, 47, 175}, uis.whiteShader); // Right side
Atoms::DrawHandlePic({147, 365, 65, 18}, uis.whiteShader); // Bottom Left
Atoms::DrawHandlePic({477, 365, 65, 18}, uis.whiteShader); // Bottom Right
UI_DrawHandlePic(145, 175, 395, 18, uis.whiteShader); // Top
UI_DrawHandlePic(132, 193, 47, 175, uis.whiteShader); // Left side
UI_DrawHandlePic(510, 193, 47, 175, uis.whiteShader); // Right side
UI_DrawHandlePic(147, 365, 65, 18, uis.whiteShader); // Bottom Left
UI_DrawHandlePic(477, 365, 65, 18, uis.whiteShader); // Bottom Right
// TiM - if message is a long one, break it up and display it on separate
// lines
if (s_confirm.question_.length() < 45) {
Atoms::DrawProportionalString({345, 269}, s_confirm.question_,
UI_SMALLFONT | UI_CENTER, color_red);
} else {
int32_t numLines;
int32_t height;
int32_t y;
int32_t i, j;
int32_t spacePoint = 45;
//TiM - if message is a long one, break it up and display it on separate lines
if (strlen(s_confirm.question) < 45)
{
UI_DrawProportionalString(345, 269, s_confirm.question, UI_SMALLFONT | UI_CENTER, color_red);
}
else
{
int32_t numLines;
char *message;
char buffer[46];
int32_t height;
int32_t y;
int32_t i, j;
int32_t spacePoint = 45;
auto message = s_confirm.question_;
numLines = message.length() / 45 + 1;
height = (SMALLCHAR_HEIGHT + 4) * numLines;
y = 277 - (height * 0.5); // 269
message = s_confirm.question;
// UI_Logger( LL_DEBUG, "numLines: %i\n", numLines );
numLines = strlen(message) / 45 + 1;
height = (SMALLCHAR_HEIGHT + 4) * numLines;
y = 277 - (height * 0.5); //269
for (i = 0; i < numLines; i++) {
if (!message.empty()) {
break;
}
//UI_Logger( LL_DEBUG, "numLines: %i\n", numLines );
if (message.length() >= 45) {
for (j = 1; j <= 45; j++) {
if (message[j] == ' ')
spacePoint = j;
}
} else {
spacePoint = message.length();
}
for (i = 0; i < numLines; i++)
{
if (!message)
break;
Atoms::DrawProportionalString({345, y}, message.substr(0, spacePoint + 1),
UI_SMALLFONT | UI_CENTER, color_red);
if (strlen(message) >= 45)
{
for (j = 1; j <= 45; j++) {
if (message[j] == ' ')
spacePoint = j;
}
}
else
spacePoint = strlen(message);
y += SMALLCHAR_HEIGHT + 4;
message += s_confirm.question_.substr(spacePoint);
}
}
Q_strncpyz(buffer, message, spacePoint + 1);
//UI_Logger( LL_DEBUG, "%s\n", buffer );
Menu_Draw(&s_confirm.menu_);
UI_DrawProportionalString(345, y, buffer, UI_SMALLFONT | UI_CENTER, color_red);
y += SMALLCHAR_HEIGHT + 4;
message += spacePoint;
}
}
Menu_Draw(&s_confirm.menu);
if (s_confirm.draw)
{
s_confirm.draw();
}
UI_LogFuncEnd();
if (s_confirm.draw_) {
s_confirm.draw_();
}
}
/*
=================
ConfirmMenu_Cache
=================
*/
void ConfirmMenu_Cache(void)
{
UI_LogFuncBegin();
s_confirm.cornerPic = trap_R_RegisterShaderNoMip("menu/common/corner_ll_47_18.tga");
UI_LogFuncEnd();
void ConfirmMenu_Cache() {
s_confirm.corner_pic_ =
trap_R_RegisterShaderNoMip("menu/common/corner_ll_47_18.tga");
}
static const char* TranslateQuestion(const char *question) {
UI_LogFuncBegin();
static char translatedQuestion[128];
std::string TranslateQuestion(const std::string &question) {
if (question == "Unpure client detected. Invalid .PK3 files referenced!") {
return menu_normal_text[MNT_UNPURECLIENT];
}
if (!strcmp(question, "Unpure client detected. Invalid .PK3 files referenced!")) {
UI_LogFuncEnd();
return menu_normal_text[MNT_UNPURECLIENT];
}
if (question == "Cannot validate pure client!") {
return menu_normal_text[MNT_CANNOTVALIDATE];
}
if (!strcmp(question, "Cannot validate pure client!")) {
UI_LogFuncEnd();
return menu_normal_text[MNT_CANNOTVALIDATE];
}
if (question == "kicked") {
return menu_normal_text[MNT_KICKED];
}
if (!strcmp(question, "kicked")) {
UI_LogFuncEnd();
return menu_normal_text[MNT_KICKED];
}
if (question == "timed out") {
return menu_normal_text[MNT_TIMEDOUT];
}
if (!strcmp(question, "timed out")) {
UI_LogFuncEnd();
return menu_normal_text[MNT_TIMEDOUT];
}
if (question == "server shut down") {
return menu_normal_text[MNT_SERVERSHUTDOWN];
}
if (!strcmp(question, "server shut down")) {
UI_LogFuncEnd();
return menu_normal_text[MNT_SERVERSHUTDOWN];
}
if (question == "disconnected") {
return menu_normal_text[MNT_DISCONNECTED];
}
if (!strcmp(question, "disconnected")) {
UI_LogFuncEnd();
return menu_normal_text[MNT_DISCONNECTED];
}
if (question == "broken download") {
return menu_normal_text[MNT_BROKENDOWNLOAD];
}
if (!strcmp(question, "broken download")) {
UI_LogFuncEnd();
return menu_normal_text[MNT_BROKENDOWNLOAD];
}
if (question == "Server command overflow") {
return menu_normal_text[MNT_SERVERCOMMANDOVERFLOW];
}
if (!strcmp(question, "Server command overflow")) {
UI_LogFuncEnd();
return menu_normal_text[MNT_SERVERCOMMANDOVERFLOW];
}
if (question == "Lost reliable commands") {
return menu_normal_text[MNT_LOSTRELIABLECOMMANDS];
}
if (!strcmp(question, "Lost reliable commands")) {
UI_LogFuncEnd();
return menu_normal_text[MNT_LOSTRELIABLECOMMANDS];
}
Q_strncpyz(translatedQuestion, question, sizeof(translatedQuestion));
UI_LogFuncEnd();
return translatedQuestion;
return question;
}
/*
@ -270,74 +237,69 @@ static const char* TranslateQuestion(const char *question) {
UI_ConfirmMenu
=================
*/
void UI_ConfirmMenu(const char *question, void(*draw)(void), void(*action)(qboolean result))
{
UI_LogFuncBegin();
void UI_ConfirmMenu(const std::string &question, std::function<void()> draw,
std::function<void(bool)> action) {
s_confirm = {};
// zero set all our globals
memset(&s_confirm, 0, sizeof(s_confirm));
ConfirmMenu_Cache();
ConfirmMenu_Cache();
Mouse_Show();
Mouse_Show();
s_confirm.question_ = TranslateQuestion(question);
s_confirm.draw_ = std::move(draw);
s_confirm.action_ = std::move(action);
s_confirm.question = (char *)TranslateQuestion(question);
s_confirm.draw = draw;
s_confirm.action = action;
s_confirm.menu_.draw = ConfirmMenu_Draw;
s_confirm.menu_.key = ConfirmMenu_Key;
s_confirm.menu_.wrapAround = qtrue;
s_confirm.menu_.fullscreen = qtrue;
s_confirm.menu_.descX = MENU_DESC_X;
s_confirm.menu_.descY = MENU_DESC_Y;
s_confirm.menu_.titleX = MENU_TITLE_X;
s_confirm.menu_.titleY = MENU_TITLE_Y;
s_confirm.menu_.titleI = MNT_CONFIRMATIONMENU_TITLE;
s_confirm.menu_.footNoteEnum = MNT_CONFIRMATION;
s_confirm.menu.draw = ConfirmMenu_Draw;
s_confirm.menu.key = ConfirmMenu_Key;
s_confirm.menu.wrapAround = qtrue;
s_confirm.menu.fullscreen = qtrue;
s_confirm.menu.descX = MENU_DESC_X;
s_confirm.menu.descY = MENU_DESC_Y;
s_confirm.menu.titleX = MENU_TITLE_X;
s_confirm.menu.titleY = MENU_TITLE_Y;
s_confirm.menu.titleI = MNT_CONFIRMATIONMENU_TITLE;
s_confirm.menu.footNoteEnum = MNT_CONFIRMATION;
s_confirm.yes_.generic.type = MTYPE_BITMAP;
s_confirm.yes_.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_confirm.yes_.generic.x = 215;
s_confirm.yes_.generic.y = 365;
s_confirm.yes_.generic.callback = ConfirmMenu_Event;
s_confirm.yes_.generic.id = ID_CONFIRM_YES;
s_confirm.yes_.generic.name = GRAPHIC_SQUARE;
s_confirm.yes_.width = MENU_BUTTON_MED_WIDTH;
s_confirm.yes_.height = MENU_BUTTON_MED_HEIGHT;
s_confirm.yes_.color = CT_DKPURPLE1;
s_confirm.yes_.color2 = CT_LTPURPLE1;
s_confirm.yes_.textX = MENU_BUTTON_TEXT_X;
s_confirm.yes_.textY = MENU_BUTTON_TEXT_Y;
s_confirm.yes_.textEnum = MBT_GENERIC_YES;
s_confirm.yes_.textcolor = CT_BLACK;
s_confirm.yes_.textcolor2 = CT_WHITE;
s_confirm.yes.generic.type = MTYPE_BITMAP;
s_confirm.yes.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_confirm.yes.generic.x = 215;
s_confirm.yes.generic.y = 365;
s_confirm.yes.generic.callback = ConfirmMenu_Event;
s_confirm.yes.generic.id = ID_CONFIRM_YES;
s_confirm.yes.generic.name = GRAPHIC_SQUARE;
s_confirm.yes.width = MENU_BUTTON_MED_WIDTH;
s_confirm.yes.height = MENU_BUTTON_MED_HEIGHT;
s_confirm.yes.color = CT_DKPURPLE1;
s_confirm.yes.color2 = CT_LTPURPLE1;
s_confirm.yes.textX = MENU_BUTTON_TEXT_X;
s_confirm.yes.textY = MENU_BUTTON_TEXT_Y;
s_confirm.yes.textEnum = MBT_GENERIC_YES;
s_confirm.yes.textcolor = CT_BLACK;
s_confirm.yes.textcolor2 = CT_WHITE;
s_confirm.no_.generic.type = MTYPE_BITMAP;
s_confirm.no_.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_confirm.no_.generic.x = 371;
s_confirm.no_.generic.y = 365;
s_confirm.no_.generic.callback = ConfirmMenu_Event;
s_confirm.no_.generic.id = ID_CONFIRM_NO;
s_confirm.no_.generic.name = GRAPHIC_SQUARE;
s_confirm.no_.width = 103;
s_confirm.no_.height = MENU_BUTTON_MED_HEIGHT;
s_confirm.no_.color = CT_DKPURPLE1;
s_confirm.no_.color2 = CT_LTPURPLE1;
s_confirm.no_.textX = MENU_BUTTON_TEXT_X;
s_confirm.no_.textY = MENU_BUTTON_TEXT_Y;
s_confirm.no_.textEnum = MBT_GENERIC_NO;
s_confirm.no_.textcolor = CT_BLACK;
s_confirm.no_.textcolor2 = CT_WHITE;
s_confirm.no.generic.type = MTYPE_BITMAP;
s_confirm.no.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_confirm.no.generic.x = 371;
s_confirm.no.generic.y = 365;
s_confirm.no.generic.callback = ConfirmMenu_Event;
s_confirm.no.generic.id = ID_CONFIRM_NO;
s_confirm.no.generic.name = GRAPHIC_SQUARE;
s_confirm.no.width = 103;
s_confirm.no.height = MENU_BUTTON_MED_HEIGHT;
s_confirm.no.color = CT_DKPURPLE1;
s_confirm.no.color2 = CT_LTPURPLE1;
s_confirm.no.textX = MENU_BUTTON_TEXT_X;
s_confirm.no.textY = MENU_BUTTON_TEXT_Y;
s_confirm.no.textEnum = MBT_GENERIC_NO;
s_confirm.no.textcolor = CT_BLACK;
s_confirm.no.textcolor2 = CT_WHITE;
Menu_AddItem(&s_confirm.menu_, &s_confirm.yes_);
if (s_confirm.action_) {
Menu_AddItem(&s_confirm.menu_, &s_confirm.no_);
}
Menu_AddItem(&s_confirm.menu, &s_confirm.yes);
if (action) {
Menu_AddItem(&s_confirm.menu, &s_confirm.no);
}
UI_PushMenu(&s_confirm.menu_);
UI_PushMenu(&s_confirm.menu);
Menu_SetCursorToItem(&s_confirm.menu, &s_confirm.no);
UI_LogFuncEnd();
Menu_SetCursorToItem(&s_confirm.menu_, &s_confirm.no_);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -4,10 +4,11 @@
#define __UI_LOCAL_H__
#include "../base_game//q_shared.h"
#include "../cgame/tr_types.h"
#include "ui_public.h"
#include "keycodes.h"
#include "../base_game/bg_public.h"
#include "../cgame/tr_types.h"
#include "keycodes.h"
#include "ui_public.h"
#include <functional>
//RPG-X : TiM
//Defines for animation code in UI module
@ -1803,7 +1804,8 @@ extern void UI_InGameMenu(void);
// ui_confirm.c
//
extern void ConfirmMenu_Cache(void);
extern void UI_ConfirmMenu(const char *question, void(*draw)(void), void(*action)(qboolean result));
void UI_ConfirmMenu(const std::string& question, std::function<void()> draw,
std::function<void(bool)> action);
//
// ui_connect.c
@ -1842,7 +1844,7 @@ enum ui_localMenu_e {
//
extern void UI_MotdMenu(void);
extern void UI_MotdMenu_Cache(void);
extern void MotdReceiveLine(const char *txt);
extern void MotdReceiveLine(std::string_view txt);
extern void MotdReset(void);
//

View file

@ -1,40 +1,37 @@
/**********************************************************************
UI_MOTD.C
UI_MOTD.C
The MotD thing
RPG-X - Marcin - 15/12/2008
**********************************************************************/
The MotD thing
RPG-X - Marcin - 15/12/2008
**********************************************************************/
#include "../qcommon/stv_version.h"
#include "ui_local.h"
#include "ui_logger.h"
enum ui_motdIDs_e {
ID_CONTINUE = 10,
ID_DISCONNECT,
ID_ARROWUP = 100,
ID_ARROWDOWN
ID_CONTINUE = 10,
ID_DISCONNECT,
ID_ARROWUP = 100,
ID_ARROWDOWN
};
enum ui_motdLimits_e {
MIN_MOTD_LINES = 20,
MAX_MOTD_LINES = 256
};
enum ui_motdLimits_e { MIN_MOTD_LINES = 20, MAX_MOTD_LINES = 256 };
extern void InGame_LeaveAction(qboolean result);
extern void InGame_LeaveAction(bool result);
char motdtext[MAX_MOTD_LINES][256];
int32_t motdtextnum;
typedef struct {
menuframework_s menu;
menubitmap_s quitmenu;
menubitmap_s disconnect;
menubitmap_s arrowdwn;
menubitmap_s arrowup;
menuframework_s menu;
menubitmap_s quitmenu;
menubitmap_s disconnect;
menubitmap_s arrowdwn;
menubitmap_s arrowup;
int32_t scrollnum;
qhandle_t halfroundl_22;
int32_t scrollnum;
qhandle_t halfroundl_22;
} motdstuff_t;
static motdstuff_t s_motdstuff;
@ -44,33 +41,32 @@ static motdstuff_t s_motdstuff;
M_Motd_Event
=================
*/
static void M_MotdMenu_Event(void *ptr, int32_t notification)
{
UI_LogFuncBegin();
if (notification != QM_ACTIVATED) {
UI_LogFuncEnd();
return;
}
static void M_MotdMenu_Event(void *ptr, int32_t notification) {
UI_LogFuncBegin();
if (notification != QM_ACTIVATED) {
UI_LogFuncEnd();
return;
}
switch (((menucommon_s*)ptr)->id) {
case ID_DISCONNECT:
UI_ConfirmMenu(menu_normal_text[MNT_LEAVE_MATCH], 0, InGame_LeaveAction);
break;
case ID_CONTINUE:
UI_PopMenu();
break;
case ID_ARROWUP:
if (s_motdstuff.scrollnum > 0) {
s_motdstuff.scrollnum -= 3;
}
switch (((menucommon_s *)ptr)->id) {
case ID_DISCONNECT:
UI_ConfirmMenu(menu_normal_text[MNT_LEAVE_MATCH], 0, InGame_LeaveAction);
break;
case ID_CONTINUE:
UI_PopMenu();
break;
case ID_ARROWUP:
if (s_motdstuff.scrollnum > 0) {
s_motdstuff.scrollnum -= 3;
}
break;
case ID_ARROWDOWN:
if (s_motdstuff.scrollnum + MIN_MOTD_LINES < motdtextnum) {
s_motdstuff.scrollnum += 3;
}
}
UI_LogFuncEnd();
break;
case ID_ARROWDOWN:
if (s_motdstuff.scrollnum + MIN_MOTD_LINES < motdtextnum) {
s_motdstuff.scrollnum += 3;
}
}
UI_LogFuncEnd();
}
/*
@ -78,11 +74,10 @@ static void M_MotdMenu_Event(void *ptr, int32_t notification)
MotdMenu_Key
=================
*/
sfxHandle_t MotdMenu_Key(int32_t key)
{
UI_LogFuncBegin();
UI_LogFuncEnd();
return (Menu_DefaultKey(&s_motdstuff.menu, key));
sfxHandle_t MotdMenu_Key(int32_t key) {
UI_LogFuncBegin();
UI_LogFuncEnd();
return (Menu_DefaultKey(&s_motdstuff.menu, key));
}
/*
@ -90,39 +85,41 @@ sfxHandle_t MotdMenu_Key(int32_t key)
M_MotdMenu_Graphics
=================
*/
static void M_MotdMenu_Graphics(void)
{
UI_LogFuncBegin();
int32_t i;
int32_t x = 15;
int32_t y = 15;
static void M_MotdMenu_Graphics(void) {
UI_LogFuncBegin();
int32_t i;
int32_t x = 15;
int32_t y = 15;
for (i = s_motdstuff.scrollnum; i < motdtextnum && i < (MIN_MOTD_LINES + s_motdstuff.scrollnum); ++i) {
UI_DrawProportionalString(x, y, motdtext[i], UI_SMALLFONT | UI_LEFT, colorTable[CT_WHITE]);
y += 21;
}
for (i = s_motdstuff.scrollnum;
i < motdtextnum && i < (MIN_MOTD_LINES + s_motdstuff.scrollnum); ++i) {
UI_DrawProportionalString(x, y, motdtext[i], UI_SMALLFONT | UI_LEFT,
colorTable[CT_WHITE]);
y += 21;
}
//UI_FrameBottom_Graphics(); // Bottom two thirds
// UI_FrameBottom_Graphics(); // Bottom two thirds
// Print version
UI_DrawProportionalString(371, 445, Q3_VERSION, UI_TINYFONT, colorTable[CT_BLACK]);
// Print version
UI_DrawProportionalString(371, 445, Q3_VERSION, UI_TINYFONT,
colorTable[CT_BLACK]);
trap_R_SetColor(colorTable[s_motdstuff.quitmenu.color]);
UI_DrawHandlePic(s_motdstuff.quitmenu.generic.x - 14,
s_motdstuff.quitmenu.generic.y,
MENU_BUTTON_MED_HEIGHT, s_motdstuff.quitmenu.height, uis.graphicButtonLeftEnd);
UI_DrawHandlePic(s_motdstuff.disconnect.generic.x - 14,
s_motdstuff.disconnect.generic.y,
MENU_BUTTON_MED_HEIGHT, s_motdstuff.disconnect.height, uis.graphicButtonLeftEnd);
trap_R_SetColor(colorTable[s_motdstuff.quitmenu.color]);
UI_DrawHandlePic(s_motdstuff.quitmenu.generic.x - 14,
s_motdstuff.quitmenu.generic.y, MENU_BUTTON_MED_HEIGHT,
s_motdstuff.quitmenu.height, uis.graphicButtonLeftEnd);
UI_DrawHandlePic(s_motdstuff.disconnect.generic.x - 14,
s_motdstuff.disconnect.generic.y, MENU_BUTTON_MED_HEIGHT,
s_motdstuff.disconnect.height, uis.graphicButtonLeftEnd);
trap_R_SetColor(colorTable[CT_LTBLUE1]); //LTBROWN1]);
UI_DrawHandlePic(28, 440, 287, 17, uis.whiteShader); // Bottom front Line
trap_R_SetColor(colorTable[CT_LTBLUE1]); // LTBROWN1]);
UI_DrawHandlePic(28, 440, 287, 17, uis.whiteShader); // Bottom front Line
UI_DrawHandlePic(0, 440, 25, 25, s_motdstuff.halfroundl_22);
UI_DrawHandlePic(319, 440, 25, 25, uis.halfroundr_22);
UI_DrawHandlePic(0, 440, 25, 25, s_motdstuff.halfroundl_22);
UI_DrawHandlePic(319, 440, 25, 25, uis.halfroundr_22);
trap_R_SetColor(NULL);
UI_LogFuncEnd();
trap_R_SetColor(NULL);
UI_LogFuncEnd();
}
/*
@ -130,12 +127,11 @@ static void M_MotdMenu_Graphics(void)
MotdMenu_Draw
===============
*/
static void MotdMenu_Draw(void)
{
UI_LogFuncBegin();
M_MotdMenu_Graphics();
UI_LogFuncEnd();
Menu_Draw(&s_motdstuff.menu);
static void MotdMenu_Draw(void) {
UI_LogFuncBegin();
M_MotdMenu_Graphics();
UI_LogFuncEnd();
Menu_Draw(&s_motdstuff.menu);
}
/*
@ -143,11 +139,11 @@ static void MotdMenu_Draw(void)
UI_MotdMenu_Cache
===============
*/
void UI_MotdMenu_Cache(void)
{
UI_LogFuncBegin();
s_motdstuff.halfroundl_22 = trap_R_RegisterShaderNoMip("menu/common/halfroundl_22.tga");
UI_LogFuncEnd();
void UI_MotdMenu_Cache(void) {
UI_LogFuncBegin();
s_motdstuff.halfroundl_22 =
trap_R_RegisterShaderNoMip("menu/common/halfroundl_22.tga");
UI_LogFuncEnd();
}
/*
@ -155,91 +151,90 @@ void UI_MotdMenu_Cache(void)
MotdMenu_Init
===============
*/
void MotdMenu_Init(void)
{
UI_LogFuncBegin();
s_motdstuff.menu.nitems = 0;
s_motdstuff.menu.draw = MotdMenu_Draw;
s_motdstuff.menu.key = MotdMenu_Key;
s_motdstuff.menu.wrapAround = qtrue;
s_motdstuff.menu.descX = MENU_DESC_X;
s_motdstuff.menu.descY = MENU_DESC_Y;
s_motdstuff.menu.titleX = MENU_TITLE_X;
s_motdstuff.menu.titleY = MENU_TITLE_Y;
void MotdMenu_Init(void) {
UI_LogFuncBegin();
s_motdstuff.menu.nitems = 0;
s_motdstuff.menu.draw = MotdMenu_Draw;
s_motdstuff.menu.key = MotdMenu_Key;
s_motdstuff.menu.wrapAround = qtrue;
s_motdstuff.menu.descX = MENU_DESC_X;
s_motdstuff.menu.descY = MENU_DESC_Y;
s_motdstuff.menu.titleX = MENU_TITLE_X;
s_motdstuff.menu.titleY = MENU_TITLE_Y;
s_motdstuff.quitmenu.generic.type = MTYPE_BITMAP;
s_motdstuff.quitmenu.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_motdstuff.quitmenu.generic.x = 500;
s_motdstuff.quitmenu.generic.y = 440;
s_motdstuff.quitmenu.generic.name = GRAPHIC_BUTTONRIGHT;
s_motdstuff.quitmenu.generic.id = ID_CONTINUE;
s_motdstuff.quitmenu.generic.callback = M_MotdMenu_Event;
s_motdstuff.quitmenu.width = MENU_BUTTON_MED_WIDTH;
s_motdstuff.quitmenu.height = MENU_BUTTON_MED_HEIGHT;
s_motdstuff.quitmenu.color = CT_DKORANGE;
s_motdstuff.quitmenu.color2 = CT_LTORANGE;
s_motdstuff.quitmenu.textX = MENU_BUTTON_TEXT_X;
s_motdstuff.quitmenu.textY = MENU_BUTTON_TEXT_Y;
s_motdstuff.quitmenu.textEnum = MBT_CONTINUE;
s_motdstuff.quitmenu.textcolor = CT_BLACK;
s_motdstuff.quitmenu.textcolor2 = CT_WHITE;
s_motdstuff.quitmenu.generic.type = MTYPE_BITMAP;
s_motdstuff.quitmenu.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_motdstuff.quitmenu.generic.x = 500;
s_motdstuff.quitmenu.generic.y = 440;
s_motdstuff.quitmenu.generic.name = GRAPHIC_BUTTONRIGHT;
s_motdstuff.quitmenu.generic.id = ID_CONTINUE;
s_motdstuff.quitmenu.generic.callback = M_MotdMenu_Event;
s_motdstuff.quitmenu.width = MENU_BUTTON_MED_WIDTH;
s_motdstuff.quitmenu.height = MENU_BUTTON_MED_HEIGHT;
s_motdstuff.quitmenu.color = CT_DKORANGE;
s_motdstuff.quitmenu.color2 = CT_LTORANGE;
s_motdstuff.quitmenu.textX = MENU_BUTTON_TEXT_X;
s_motdstuff.quitmenu.textY = MENU_BUTTON_TEXT_Y;
s_motdstuff.quitmenu.textEnum = MBT_CONTINUE;
s_motdstuff.quitmenu.textcolor = CT_BLACK;
s_motdstuff.quitmenu.textcolor2 = CT_WHITE;
s_motdstuff.disconnect.generic.type = MTYPE_BITMAP;
s_motdstuff.disconnect.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_motdstuff.disconnect.generic.x = 350;
s_motdstuff.disconnect.generic.y = 440;
s_motdstuff.disconnect.generic.name = GRAPHIC_BUTTONRIGHT;
s_motdstuff.disconnect.generic.id = ID_DISCONNECT;
s_motdstuff.disconnect.generic.callback = M_MotdMenu_Event;
s_motdstuff.disconnect.width = MENU_BUTTON_MED_WIDTH;
s_motdstuff.disconnect.height = MENU_BUTTON_MED_HEIGHT;
s_motdstuff.disconnect.color = CT_DKORANGE;
s_motdstuff.disconnect.color2 = CT_LTORANGE;
s_motdstuff.disconnect.textX = MENU_BUTTON_TEXT_X;
s_motdstuff.disconnect.textY = MENU_BUTTON_TEXT_Y;
s_motdstuff.disconnect.textEnum = MBT_INGAMELEAVE;
s_motdstuff.disconnect.textcolor = CT_BLACK;
s_motdstuff.disconnect.textcolor2 = CT_WHITE;
s_motdstuff.disconnect.generic.type = MTYPE_BITMAP;
s_motdstuff.disconnect.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_motdstuff.disconnect.generic.x = 350;
s_motdstuff.disconnect.generic.y = 440;
s_motdstuff.disconnect.generic.name = GRAPHIC_BUTTONRIGHT;
s_motdstuff.disconnect.generic.id = ID_DISCONNECT;
s_motdstuff.disconnect.generic.callback = M_MotdMenu_Event;
s_motdstuff.disconnect.width = MENU_BUTTON_MED_WIDTH;
s_motdstuff.disconnect.height = MENU_BUTTON_MED_HEIGHT;
s_motdstuff.disconnect.color = CT_DKORANGE;
s_motdstuff.disconnect.color2 = CT_LTORANGE;
s_motdstuff.disconnect.textX = MENU_BUTTON_TEXT_X;
s_motdstuff.disconnect.textY = MENU_BUTTON_TEXT_Y;
s_motdstuff.disconnect.textEnum = MBT_INGAMELEAVE;
s_motdstuff.disconnect.textcolor = CT_BLACK;
s_motdstuff.disconnect.textcolor2 = CT_WHITE;
s_motdstuff.arrowup.generic.type = MTYPE_BITMAP;
s_motdstuff.arrowup.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_motdstuff.arrowup.generic.x = 610;
s_motdstuff.arrowup.generic.y = 10;
s_motdstuff.arrowup.generic.name = "menu/common/arrow_up_16.tga";
s_motdstuff.arrowup.generic.id = ID_ARROWUP;
s_motdstuff.arrowup.generic.callback = M_MotdMenu_Event;
s_motdstuff.arrowup.width = 16;
s_motdstuff.arrowup.height = 16;
s_motdstuff.arrowup.color = CT_DKBLUE1;
s_motdstuff.arrowup.color2 = CT_LTBLUE1;
s_motdstuff.arrowup.textX = 0;
s_motdstuff.arrowup.textY = 0;
s_motdstuff.arrowup.textEnum = MBT_NONE;
s_motdstuff.arrowup.textcolor = CT_BLACK;
s_motdstuff.arrowup.textcolor2 = CT_WHITE;
s_motdstuff.arrowup.generic.type = MTYPE_BITMAP;
s_motdstuff.arrowup.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_motdstuff.arrowup.generic.x = 610;
s_motdstuff.arrowup.generic.y = 10;
s_motdstuff.arrowup.generic.name = "menu/common/arrow_up_16.tga";
s_motdstuff.arrowup.generic.id = ID_ARROWUP;
s_motdstuff.arrowup.generic.callback = M_MotdMenu_Event;
s_motdstuff.arrowup.width = 16;
s_motdstuff.arrowup.height = 16;
s_motdstuff.arrowup.color = CT_DKBLUE1;
s_motdstuff.arrowup.color2 = CT_LTBLUE1;
s_motdstuff.arrowup.textX = 0;
s_motdstuff.arrowup.textY = 0;
s_motdstuff.arrowup.textEnum = MBT_NONE;
s_motdstuff.arrowup.textcolor = CT_BLACK;
s_motdstuff.arrowup.textcolor2 = CT_WHITE;
s_motdstuff.arrowdwn.generic.type = MTYPE_BITMAP;
s_motdstuff.arrowdwn.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_motdstuff.arrowdwn.generic.x = 610;
s_motdstuff.arrowdwn.generic.y = 420;
s_motdstuff.arrowdwn.generic.name = "menu/common/arrow_dn_16.tga";
s_motdstuff.arrowdwn.generic.id = ID_ARROWDOWN;
s_motdstuff.arrowdwn.generic.callback = M_MotdMenu_Event;
s_motdstuff.arrowdwn.width = 16;
s_motdstuff.arrowdwn.height = 16;
s_motdstuff.arrowdwn.color = CT_DKBLUE1;
s_motdstuff.arrowdwn.color2 = CT_LTBLUE1;
s_motdstuff.arrowdwn.textX = 0;
s_motdstuff.arrowdwn.textY = 0;
s_motdstuff.arrowdwn.textEnum = MBT_NONE;
s_motdstuff.arrowdwn.textcolor = CT_BLACK;
s_motdstuff.arrowdwn.textcolor2 = CT_WHITE;
s_motdstuff.arrowdwn.generic.type = MTYPE_BITMAP;
s_motdstuff.arrowdwn.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_motdstuff.arrowdwn.generic.x = 610;
s_motdstuff.arrowdwn.generic.y = 420;
s_motdstuff.arrowdwn.generic.name = "menu/common/arrow_dn_16.tga";
s_motdstuff.arrowdwn.generic.id = ID_ARROWDOWN;
s_motdstuff.arrowdwn.generic.callback = M_MotdMenu_Event;
s_motdstuff.arrowdwn.width = 16;
s_motdstuff.arrowdwn.height = 16;
s_motdstuff.arrowdwn.color = CT_DKBLUE1;
s_motdstuff.arrowdwn.color2 = CT_LTBLUE1;
s_motdstuff.arrowdwn.textX = 0;
s_motdstuff.arrowdwn.textY = 0;
s_motdstuff.arrowdwn.textEnum = MBT_NONE;
s_motdstuff.arrowdwn.textcolor = CT_BLACK;
s_motdstuff.arrowdwn.textcolor2 = CT_WHITE;
Menu_AddItem(&s_motdstuff.menu, &s_motdstuff.quitmenu);
Menu_AddItem(&s_motdstuff.menu, &s_motdstuff.disconnect);
Menu_AddItem(&s_motdstuff.menu, &s_motdstuff.arrowup);
Menu_AddItem(&s_motdstuff.menu, &s_motdstuff.arrowdwn);
UI_LogFuncEnd();
Menu_AddItem(&s_motdstuff.menu, &s_motdstuff.quitmenu);
Menu_AddItem(&s_motdstuff.menu, &s_motdstuff.disconnect);
Menu_AddItem(&s_motdstuff.menu, &s_motdstuff.arrowup);
Menu_AddItem(&s_motdstuff.menu, &s_motdstuff.arrowdwn);
UI_LogFuncEnd();
}
/*
@ -247,16 +242,15 @@ void MotdMenu_Init(void)
MotdReset
===============
*/
void MotdReset(void)
{
UI_LogFuncBegin();
int32_t i;
void MotdReset(void) {
UI_LogFuncBegin();
int32_t i;
motdtextnum = 0;
for (i = 0; i < MAX_MOTD_LINES; ++i) {
*motdtext[i] = '\0';
}
UI_LogFuncEnd();
motdtextnum = 0;
for (i = 0; i < MAX_MOTD_LINES; ++i) {
*motdtext[i] = '\0';
}
UI_LogFuncEnd();
}
/*
@ -264,12 +258,9 @@ void MotdReset(void)
MotdReceiveLine
===============
*/
void MotdReceiveLine(const char *txt)
{
UI_LogFuncBegin();
Q_strncpyz(motdtext[motdtextnum], txt, sizeof (motdtext[motdtextnum]));
motdtextnum++;
UI_LogFuncEnd();
void MotdReceiveLine(std::string_view txt) {
Q_strncpyz(motdtext[motdtextnum], txt.data(), sizeof(motdtext[motdtextnum]));
motdtextnum++;
}
/*
@ -277,23 +268,22 @@ void MotdReceiveLine(const char *txt)
UI_MotdMenu
===============
*/
void UI_MotdMenu(void)
{
UI_LogFuncBegin();
memset(&s_motdstuff, 0, sizeof(s_motdstuff));
void UI_MotdMenu(void) {
UI_LogFuncBegin();
memset(&s_motdstuff, 0, sizeof(s_motdstuff));
uis.menusp = 0;
uis.menusp = 0;
ingameFlag = qtrue;
ingameFlag = qtrue;
Mouse_Show();
Mouse_Show();
UI_MotdMenu_Cache();
UI_MotdMenu_Cache();
MotdMenu_Init();
MotdMenu_Init();
UI_PushMenu(&s_motdstuff.menu);
UI_PushMenu(&s_motdstuff.menu);
Menu_AdjustCursor(&s_motdstuff.menu, 1);
UI_LogFuncEnd();
Menu_AdjustCursor(&s_motdstuff.menu, 1);
UI_LogFuncEnd();
}

View file

@ -57,7 +57,6 @@ void TransDataReceived(const char *data) {
char *temp;
int32_t i;
UI_LogFuncBegin();
for (i = 0; i < 6; i++) {
temp = Info_ValueForKey(data, va("d%i", i));
@ -65,7 +64,6 @@ void TransDataReceived(const char *data) {
Q_strncpyz(srvList[i], temp, sizeof(srvList[i]));
srvCount++;
}
UI_LogFuncEnd();
}
/*

View file

@ -1139,14 +1139,12 @@ static void GraphicsOptions_SetMenuItems(void)
void VideoSideButtonsAction(qboolean result)
void VideoSideButtonsAction(bool result)
{
UI_LogFuncBegin();
if (result) // Yes - do it
{
Video_MenuEvent(holdControlPtr, holdControlEvent);
}
UI_LogFuncEnd();
}
/*