Don't show entering reduced performance mode in regular chat, move it to topright status

This commit is contained in:
UnknownShadow200 2022-05-18 22:16:44 +10:00
parent 5a0f83c650
commit 11846d8ac8
6 changed files with 44 additions and 23 deletions

View file

@ -19,14 +19,20 @@
#include "Options.h"
#include "Drawer2D.h"
static char msgs[12][STRING_SIZE];
cc_string Chat_Status[4] = { String_FromArray(msgs[0]), String_FromArray(msgs[1]), String_FromArray(msgs[2]), String_FromArray(msgs[3]) };
cc_string Chat_BottomRight[3] = { String_FromArray(msgs[4]), String_FromArray(msgs[5]), String_FromArray(msgs[6]) };
cc_string Chat_ClientStatus[2] = { String_FromArray(msgs[7]), String_FromArray(msgs[8]) };
static char _st[5][STRING_SIZE];
static char _br[3][STRING_SIZE];
static char _cs[2][STRING_SIZE];
static char announcement[STRING_SIZE];
static char bigAnnouncement[STRING_SIZE];
static char smallAnnouncement[STRING_SIZE];
cc_string Chat_Announcement = String_FromArray(msgs[9]);
cc_string Chat_BigAnnouncement = String_FromArray(msgs[10]);
cc_string Chat_SmallAnnouncement = String_FromArray(msgs[11]);
cc_string Chat_Status[5] = { String_FromArray(_st[0]), String_FromArray(_st[1]), String_FromArray(_st[2]), String_FromArray(_st[3]), String_FromArray(_st[4]) };
cc_string Chat_BottomRight[3] = { String_FromArray(_br[0]), String_FromArray(_br[1]), String_FromArray(_br[2]) };
cc_string Chat_ClientStatus[2] = { String_FromArray(_cs[0]), String_FromArray(_cs[8]) };
cc_string Chat_Announcement = String_FromArray(announcement);
cc_string Chat_BigAnnouncement = String_FromArray(bigAnnouncement);
cc_string Chat_SmallAnnouncement = String_FromArray(smallAnnouncement);
double Chat_AnnouncementReceived;
double Chat_BigAnnouncementReceived;
@ -234,7 +240,8 @@ void Chat_AddOf(const cc_string* text, int msgType) {
AppendChatLog(text);
} else if (msgType >= MSG_TYPE_STATUS_1 && msgType <= MSG_TYPE_STATUS_3) {
/* Status[0] is for texture pack downloading message */
String_Copy(&Chat_Status[1 + (msgType - MSG_TYPE_STATUS_1)], text);
/* Status[1] is for reduced performance mode message */
String_Copy(&Chat_Status[2 + (msgType - MSG_TYPE_STATUS_1)], text);
} else if (msgType >= MSG_TYPE_BOTTOMRIGHT_1 && msgType <= MSG_TYPE_BOTTOMRIGHT_3) {
String_Copy(&Chat_BottomRight[msgType - MSG_TYPE_BOTTOMRIGHT_1], text);
} else if (msgType == MSG_TYPE_ANNOUNCEMENT) {
@ -248,7 +255,9 @@ void Chat_AddOf(const cc_string* text, int msgType) {
Chat_SmallAnnouncementReceived = Game.Time;
} else if (msgType >= MSG_TYPE_CLIENTSTATUS_1 && msgType <= MSG_TYPE_CLIENTSTATUS_2) {
String_Copy(&Chat_ClientStatus[msgType - MSG_TYPE_CLIENTSTATUS_1], text);
}
} else if (msgType >= MSG_TYPE_EXTRASTATUS_1 && msgType <= MSG_TYPE_EXTRASTATUS_2) {
String_Copy(&Chat_Status[msgType - MSG_TYPE_EXTRASTATUS_1], text);
}
Event_RaiseChat(&ChatEvents.ChatReceived, text, msgType);
}

View file

@ -20,10 +20,12 @@ enum MsgType {
MSG_TYPE_BIGANNOUNCEMENT = 101,
MSG_TYPE_SMALLANNOUNCEMENT = 102,
MSG_TYPE_CLIENTSTATUS_1 = 256, /* Cuboid messages */
MSG_TYPE_CLIENTSTATUS_2 = 257 /* Tab list matching names */
MSG_TYPE_CLIENTSTATUS_2 = 257, /* Tab list matching names */
MSG_TYPE_EXTRASTATUS_1 = 360,
MSG_TYPE_EXTRASTATUS_2 = 361
};
extern cc_string Chat_Status[4], Chat_BottomRight[3], Chat_ClientStatus[2];
extern cc_string Chat_Status[5], Chat_BottomRight[3], Chat_ClientStatus[2];
extern cc_string Chat_Announcement, Chat_BigAnnouncement, Chat_SmallAnnouncement;
/* All chat messages received. */
extern struct StringsBuffer Chat_Log;

View file

@ -276,11 +276,12 @@ static void HandleOnNewMapLoaded(void* obj) {
static void HandleInactiveChanged(void* obj) {
if (WindowInfo.Inactive) {
Chat_AddRaw(LOWPERF_ENTER_MESSAGE);
Chat_AddOf(&Gfx_LowPerfMessage, MSG_TYPE_EXTRASTATUS_2);
Gfx_SetFpsLimit(false, 1000 / 1.0f);
} else {
Chat_AddRaw(LOWPERF_EXIT_MESSAGE);
Chat_AddOf(&String_Empty, MSG_TYPE_EXTRASTATUS_2);
Game_SetFpsLimit(Game_FpsLimit);
Chat_AddRaw(LOWPERF_EXIT_MESSAGE);
}
#ifdef CC_BUILD_WEB

View file

@ -50,6 +50,7 @@ CC_VAR extern struct _GfxData {
extern GfxResourceID Gfx_defaultIb;
extern GfxResourceID Gfx_quadVb, Gfx_texVb;
extern const cc_string Gfx_LowPerfMessage;
#define ICOUNT(verticesCount) (((verticesCount) >> 2) * 6)
#define GFX_MAX_INDICES (65536 / 4 * 6)
@ -60,7 +61,6 @@ extern GfxResourceID Gfx_quadVb, Gfx_texVb;
/* Texture should allow updating via Gfx_UpdateTexture */
#define TEXTURE_FLAG_DYNAMIC 0x02
#define LOWPERF_ENTER_MESSAGE "&eEntering reduced performance mode (game minimised or hidden)"
#define LOWPERF_EXIT_MESSAGE "&eExited reduced performance mode"
void Gfx_RecreateDynamicVb(GfxResourceID* vb, VertexFormat fmt, int maxVertices);

View file

@ -896,19 +896,20 @@ static void ChatScreen_EnterChatInput(struct ChatScreen* s, cc_bool close) {
static void ChatScreen_UpdateTexpackStatus(struct ChatScreen* s) {
int progress = Http_CheckProgress(TexturePack_ReqID);
cc_string msg; char msgBuffer[STRING_SIZE];
if (progress == s->lastDownloadStatus) return;
s->lastDownloadStatus = progress;
Chat_Status[0].length = 0;
String_InitArray(msg, msgBuffer);
if (progress == HTTP_PROGRESS_MAKING_REQUEST) {
String_AppendConst(&Chat_Status[0], "&eRetrieving texture pack..");
String_AppendConst(&msg, "&eRetrieving texture pack..");
} else if (progress == HTTP_PROGRESS_FETCHING_DATA) {
String_AppendConst(&Chat_Status[0], "&eDownloading texture pack");
String_AppendConst(&msg, "&eDownloading texture pack");
} else if (progress >= 0 && progress <= 100) {
String_Format1(&Chat_Status[0], "&eDownloading texture pack (&7%i&e%%)", &progress);
String_Format1(&msg, "&eDownloading texture pack (&7%i&e%%)", &progress);
}
TextGroupWidget_Redraw(&s->status, 0);
Chat_AddOf(&msg, MSG_TYPE_EXTRASTATUS_1);
}
static void ChatScreen_ColCodeChanged(void* screen, int code) {
@ -939,7 +940,8 @@ static void ChatScreen_ChatReceived(void* screen, const cc_string* msg, int type
TextGroupWidget_ShiftUp(&s->chat);
} else if (type >= MSG_TYPE_STATUS_1 && type <= MSG_TYPE_STATUS_3) {
/* Status[0] is for texture pack downloading message */
TextGroupWidget_Redraw(&s->status, 1 + (type - MSG_TYPE_STATUS_1));
/* Status[1] is for reduced performance mode message */
TextGroupWidget_Redraw(&s->status, 2 + (type - MSG_TYPE_STATUS_1));
} else if (type >= MSG_TYPE_BOTTOMRIGHT_1 && type <= MSG_TYPE_BOTTOMRIGHT_3) {
/* Bottom3 is top most line, so need to redraw index 0 */
TextGroupWidget_Redraw(&s->bottomRight, 2 - (type - MSG_TYPE_BOTTOMRIGHT_1));
@ -952,7 +954,11 @@ static void ChatScreen_ChatReceived(void* screen, const cc_string* msg, int type
} else if (type >= MSG_TYPE_CLIENTSTATUS_1 && type <= MSG_TYPE_CLIENTSTATUS_2) {
TextGroupWidget_Redraw(&s->clientStatus, type - MSG_TYPE_CLIENTSTATUS_1);
ChatScreen_UpdateChatYOffsets(s);
}
} else if (type >= MSG_TYPE_EXTRASTATUS_1 && type <= MSG_TYPE_EXTRASTATUS_2) {
/* Status[0] is for texture pack downloading message */
/* Status[1] is for reduced performance mode message */
TextGroupWidget_Redraw(&s->status, type - MSG_TYPE_EXTRASTATUS_1);
}
}
static void ChatScreen_DrawCrosshairs(void) {
@ -1301,7 +1307,8 @@ static void ChatScreen_Init(void* screen) {
TextWidget_Init(&s->bigAnnouncement);
TextWidget_Init(&s->smallAnnouncement);
s->status.collapsible[0] = true; /* Texture pack download status */
s->status.collapsible[0] = true; /* Texture pack downloading status */
s->status.collapsible[1] = true; /* Reduced performance mode status */
s->clientStatus.collapsible[0] = true;
s->clientStatus.collapsible[1] = true;

View file

@ -13,6 +13,7 @@
struct _GfxData Gfx;
GfxResourceID Gfx_defaultIb;
GfxResourceID Gfx_quadVb, Gfx_texVb;
const cc_string Gfx_LowPerfMessage = String_FromConst("&eRunning in reduced performance mode (game minimised or hidden)");
static const int strideSizes[2] = { SIZEOF_VERTEX_COLOURED, SIZEOF_VERTEX_TEXTURED };
/* Whether mipmaps must be created for all dimensions down to 1x1 or not */
@ -116,12 +117,13 @@ static void TickReducedPerformance(void) {
if (reducedPerformance) return;
reducedPerformance = true;
Chat_AddRaw(LOWPERF_ENTER_MESSAGE);
Chat_AddOf(&Gfx_LowPerfMessage, MSG_TYPE_EXTRASTATUS_2);
}
static void EndReducedPerformance(void) {
if (!reducedPerformance) return;
reducedPerformance = false;
Chat_AddOf(&String_Empty, MSG_TYPE_EXTRASTATUS_2);
Chat_AddRaw(LOWPERF_EXIT_MESSAGE);
}