Add more NotifyAction types

BlockListSelected, BlockListToggled, LevelSaved, Respawned, SpawnUpdated, TexturePackChanged, TexturePromptResponded
This commit is contained in:
Derek 2025-01-02 09:44:30 +10:00
parent 9889eca356
commit ce409304c4
4 changed files with 25 additions and 3 deletions

View file

@ -22,6 +22,7 @@
#include "Errors.h"
#include "Utils.h"
#include "EntityRenderers.h"
#include "Protocol.h"
const char* const NameMode_Names[NAME_MODE_COUNT] = { "None", "Hovered", "All", "AllHovered", "AllUnscaled" };
const char* const ShadowMode_Names[SHADOW_MODE_COUNT] = { "None", "SnapToBlock", "Circle", "CircleAll" };
@ -844,6 +845,8 @@ static void LocalPlayer_DoRespawn(struct LocalPlayer* p) {
Entity_GetBounds(&p->Base, &bb);
bb.Min.y -= 0.01f; bb.Max.y = bb.Min.y;
p->Base.OnGround = Entity_TouchesAny(&bb, LocalPlayer_IsSolidCollide);
CPE_SendNotifyAction(3, 0);
}
static cc_bool LocalPlayer_HandleRespawn(int key, struct InputDevice* device) {
@ -884,6 +887,8 @@ static cc_bool LocalPlayer_HandleSetSpawn(int key, struct InputDevice* device) {
p->SpawnYaw = p->Base.Yaw;
if (!Game_ClassicMode) p->SpawnPitch = p->Base.Pitch;
CPE_SendNotifyAction(4, 0);
}
return LocalPlayer_HandleRespawn(key, device);
}

View file

@ -4,6 +4,7 @@
#include "Block.h"
#include "Event.h"
#include "Chat.h"
#include "Protocol.h"
struct _InventoryData Inventory;
@ -45,6 +46,7 @@ void Inventory_SetSelectedBlock(BlockID block) {
Inventory_Set(Inventory.SelectedIndex, block);
Event_RaiseVoid(&UserEvents.HeldBlockChanged);
CPE_SendNotifyAction(0, block);
}
void Inventory_PickBlock(BlockID block) {

View file

@ -1409,14 +1409,14 @@ static void SaveLevelScreen_Save(void* screen, void* widget) {
SaveLevelScreen_RemoveOverwrites(s);
if ((res = SaveLevelScreen_SaveMap(&path))) return;
Chat_Add1("&eSaved map to: %s", &path);
CPE_SendNotifyAction(0, 0);
CPE_SendNotifyAction(2, 0);
}
static void SaveLevelScreen_UploadCallback(const cc_string* path) {
cc_result res = SaveLevelScreen_SaveMap(path);
if (!res) {
Chat_Add1("&eSaved map to: %s", path);
CPE_SendNotifyAction(0, 0);
CPE_SendNotifyAction(2, 0);
}
}
@ -1562,6 +1562,8 @@ static void TexturePackScreen_EntryClick(void* screen, void* widget) {
TexturePack_Url.length = 0;
res = TexturePack_ExtractCurrent(true);
CPE_SendNotifyAction(5, 0);
/* FileNotFound error may be because user deleted .zips from disc */
if (res != ReturnCode_FileNotFound) return;
Chat_AddRaw("&eReloading texture pack list as it may be out of date");
@ -2739,6 +2741,9 @@ static void TexPackOverlay_YesClick(void* screen, void* widget) {
TexturePack_Extract(&s->url);
if (TexPackOverlay_IsAlways(s, widget)) TextureCache_Accept(&s->url);
Gui_Remove((struct Screen*)s);
if (TexPackOverlay_IsAlways(s, widget)) CPE_SendNotifyAction(6, 3);
else CPE_SendNotifyAction(6, 2);
}
static void TexPackOverlay_NoClick(void* screen, void* widget) {
@ -2752,6 +2757,9 @@ static void TexPackOverlay_ConfirmNoClick(void* screen, void* b) {
struct TexPackOverlay* s = (struct TexPackOverlay*)screen;
if (s->alwaysDeny) TextureCache_Deny(&s->url);
Gui_Remove((struct Screen*)s);
if (s->alwaysDeny) CPE_SendNotifyAction(6, 0);
else CPE_SendNotifyAction(6, 1);
}
static void TexPackOverlay_GoBackClick(void* screen, void* b) {

View file

@ -23,6 +23,7 @@
#include "Utils.h"
#include "Options.h"
#include "InputHandler.h"
#include "Protocol.h"
#define CHAT_MAX_STATUS Array_Elems(Chat_Status)
#define CHAT_MAX_BOTTOMRIGHT Array_Elems(Chat_BottomRight)
@ -1731,9 +1732,11 @@ static int InventoryScreen_KeyDown(void* screen, int key, struct InputDevice* de
/* Accuracy: Original classic doesn't close inventory menu when B is pressed */
if (InputBind_Claims(BIND_INVENTORY, key, device) && s->releasedInv && !Game_ClassicMode) {
Gui_Remove((struct Screen*)s);
CPE_SendNotifyAction(1, 0);
} else if (InputDevice_IsEnter(key, device) && table->selectedIndex != -1) {
Inventory_SetSelectedBlock(table->blocks[table->selectedIndex]);
Gui_Remove((struct Screen*)s);
CPE_SendNotifyAction(1, 0);
} else if (Elem_HandlesKeyDown(table, key, device)) {
} else {
return Elem_HandlesKeyDown(&HUDScreen_Instance.hotbar, key, device);
@ -1763,7 +1766,10 @@ static int InventoryScreen_PointerDown(void* screen, int id, int x, int y) {
if (!handled || table->pendingClose) {
hotbar = Input_IsCtrlPressed() || Input_IsShiftPressed();
if (!hotbar) Gui_Remove((struct Screen*)s);
if (!hotbar) {
Gui_Remove((struct Screen*)s);
CPE_SendNotifyAction(1, 0);
}
}
return TOUCH_TYPE_GUI;
}
@ -1807,6 +1813,7 @@ void InventoryScreen_Show(void) {
s->VTABLE = &InventoryScreen_VTABLE;
Gui_Add((struct Screen*)s, GUI_PRIORITY_INVENTORY);
CPE_SendNotifyAction(1, 1);
}