Add NotifyAction CPE

This commit is contained in:
Derek 2024-10-05 18:56:06 +10:00
parent 1bfc86b9c3
commit cf5300149f
3 changed files with 22 additions and 4 deletions

View File

@ -36,6 +36,7 @@
#include "SystemFonts.h"
#include "Lighting.h"
#include "InputHandler.h"
#include "Protocol.h"
/*########################################################################################################################*
*--------------------------------------------------------Menu base--------------------------------------------------------*
@ -1408,11 +1409,15 @@ 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);
}
static void SaveLevelScreen_UploadCallback(const cc_string* path) {
cc_result res = SaveLevelScreen_SaveMap(path);
if (!res) Chat_Add1("&eSaved map to: %s", path);
if (!res) {
Chat_Add1("&eSaved map to: %s", path);
CPE_SendNotifyAction(0, 0);
}
}
static void SaveLevelScreen_File(void* screen, void* b) {

View File

@ -92,7 +92,8 @@ static struct CpeExt
pluginMessages_Ext = { "PluginMessages", 1 },
extTeleport_Ext = { "ExtEntityTeleport", 1 },
lightingMode_Ext = { "LightingMode", 1 },
cinematicGui_Ext = { "CinematicGui", 1 },
cinematicGui_Ext = { "CinematicGui", 1 },
notifyAction_Ext = { "NotifyAction", 1 },
extTextures_Ext = { "ExtendedTextures", 1 },
extBlocks_Ext = { "ExtendedBlocks", 1 };
@ -102,7 +103,7 @@ static struct CpeExt* cpe_clientExtensions[] = {
&messageTypes_Ext, &hackControl_Ext, &playerClick_Ext, &fullCP437_Ext, &longerMessages_Ext, &blockDefs_Ext,
&blockDefsExt_Ext, &bulkBlockUpdate_Ext, &textColors_Ext, &envMapAspect_Ext, &entityProperty_Ext, &extEntityPos_Ext,
&twoWayPing_Ext, &invOrder_Ext, &instantMOTD_Ext, &fastMap_Ext, &setHotbar_Ext, &setSpawnpoint_Ext, &velControl_Ext,
&customParticles_Ext, &pluginMessages_Ext, &extTeleport_Ext, &lightingMode_Ext, &cinematicGui_Ext,
&customParticles_Ext, &pluginMessages_Ext, &extTeleport_Ext, &lightingMode_Ext, &cinematicGui_Ext, &notifyAction_Ext,
#ifdef CUSTOM_MODELS
&customModels_Ext,
#endif
@ -896,6 +897,17 @@ void CPE_SendPluginMessage(cc_uint8 channel, cc_uint8* data) {
Server.SendData(buffer, 66);
}
void CPE_SendNotifyAction(int action, int value) {
cc_uint8 data[4];
data[0] = OPCODE_NOTIFY_ACTION;
{
data[1] = action;
data[2] = value;
}
Server.SendData(data, 4);
}
static void CPE_SendExtInfo(int extsCount) {
cc_uint8 data[67];
data[0] = OPCODE_EXT_INFO;

View File

@ -39,7 +39,7 @@ enum OPCODE_ {
OPCODE_DEFINE_EFFECT, OPCODE_SPAWN_EFFECT,
OPCODE_DEFINE_MODEL, OPCODE_DEFINE_MODEL_PART, OPCODE_UNDEFINE_MODEL,
OPCODE_PLUGIN_MESSAGE, OPCODE_ENTITY_TELEPORT_EXT,
OPCODE_LIGHTING_MODE, OPCODE_CINEMATIC_GUI,
OPCODE_LIGHTING_MODE, OPCODE_CINEMATIC_GUI, OPCODE_NOTIFY_ACTION,
OPCODE_COUNT
};
@ -71,6 +71,7 @@ void Classic_SendChat(const cc_string* text, cc_bool partial);\
void Classic_SendSetBlock(int x, int y, int z, cc_bool place, BlockID block);
void Classic_SendLogin(void);
void CPE_SendPlayerClick(int button, cc_bool pressed, cc_uint8 targetId, struct RayTracer* t);
void CPE_SendNotifyAction(int button, int value);
/* Send a PluginMessage to the server; data must contain 64 bytes. */
CC_API void CPE_SendPluginMessage(cc_uint8 channel, cc_uint8* data);