Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: take screenshot #2116

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c5f4a58
Update player.hpp
luanluciano93 Jan 16, 2024
1d9fcab
Update protocolgame.hpp
luanluciano93 Jan 16, 2024
bf31895
Update protocolgame.cpp
luanluciano93 Jan 16, 2024
74283b6
Update player_functions.cpp
luanluciano93 Jan 16, 2024
89ba528
Update player_functions.hpp
luanluciano93 Jan 16, 2024
e0aa364
Update src/lua/functions/creatures/player/player_functions.cpp
luanluciano93 Jan 17, 2024
c128489
Update src/lua/functions/creatures/player/player_functions.hpp
luanluciano93 Jan 17, 2024
5819b72
Update src/lua/functions/creatures/player/player_functions.hpp
luanluciano93 Jan 17, 2024
221fcdf
Update src/server/network/protocol/protocolgame.cpp
luanluciano93 Jan 17, 2024
ca2b3bc
Code format - (Clang-format)
github-actions[bot] Jan 17, 2024
9393a9f
Merge branch 'main' into take-screenshot
luanluciano93 Jan 18, 2024
8785930
Update protocolgame.cpp
luanluciano93 Jan 18, 2024
34e6175
Code format - (Clang-format)
github-actions[bot] Jan 18, 2024
1053279
Update utils_definitions.hpp
luanluciano93 Jan 18, 2024
f29cd8c
Code format - (Clang-format)
github-actions[bot] Jan 18, 2024
355c2e6
Update lua_enums.cpp
luanluciano93 Jan 18, 2024
216355c
Update utils_definitions.hpp
luanluciano93 Jan 18, 2024
6e11444
Code format - (Clang-format)
github-actions[bot] Jan 18, 2024
6da0ba1
Update player.hpp
luanluciano93 Jan 18, 2024
6d829be
Update player_functions.cpp
luanluciano93 Jan 18, 2024
306ef07
Update protocolgame.cpp
luanluciano93 Jan 18, 2024
6e61601
Update protocolgame.hpp
luanluciano93 Jan 18, 2024
e5a0b4b
Update player_functions.cpp
luanluciano93 Jan 20, 2024
36ff8b6
Update achievements_lib.lua
luanluciano93 Jan 20, 2024
97ea6cf
Merge branch 'main' into take-screenshot
luanluciano93 Jan 31, 2024
fbea9d2
Code format - (Clang-format)
github-actions[bot] Jan 31, 2024
6f53578
Merge remote-tracking branch 'upstream/main' into take-screenshot
luanluciano93 Feb 14, 2024
1471198
Merge remote-tracking branch 'upstream/main' into take-screenshot
luanluciano93 Mar 10, 2024
be2fb77
update
luanluciano93 Mar 10, 2024
0bad989
Code format - (Clang-format)
github-actions[bot] Mar 10, 2024
34e920d
UPDATE
luanluciano93 Mar 10, 2024
d784829
Merge branch 'take-screenshot' of https://github.com/luanluciano93/ca…
luanluciano93 Mar 10, 2024
150dd96
Update player.cpp
luanluciano93 Mar 10, 2024
370b27a
update
luanluciano93 Apr 8, 2024
bb019aa
Merge branch 'main' into take-screenshot
luanluciano93 Apr 8, 2024
4d66d13
update
luanluciano93 Apr 8, 2024
03bac3e
Merge branch 'take-screenshot' of https://github.com/luanluciano93/ca…
luanluciano93 Apr 9, 2024
76b1a33
Update player_functions.hpp
luanluciano93 Apr 10, 2024
1b53945
Update bosslever_death.lua
luanluciano93 Apr 16, 2024
2d51907
Merge branch 'main' into take-screenshot
luanluciano93 Apr 16, 2024
9d562f7
Merge branch 'main' into take-screenshot
luanluciano93 Apr 29, 2024
8951d31
Code format - (Clang-format)
github-actions[bot] Apr 29, 2024
89a3fda
Merge branch 'main' into take-screenshot
luanluciano93 May 9, 2024
8955a5d
Code format - (Clang-format)
github-actions[bot] May 9, 2024
df00cf0
Merge branch 'main' into take-screenshot
luanluciano93 May 14, 2024
6315999
Code format - (Clang-format)
github-actions[bot] May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,12 @@ class Player final : public Creature, public Cylinder, public Bankable {
}
}

void sendTakeScreenshot(uint8_t screenshotType) {
if (client) {
client->sendTakeScreenshot(screenshotType);
}
}

void onThink(uint32_t interval) override;

void postAddNotification(std::shared_ptr<Thing> thing, std::shared_ptr<Cylinder> oldParent, int32_t index, CylinderLink_t link = LINK_OWNER) override;
Expand Down
14 changes: 14 additions & 0 deletions src/lua/functions/creatures/player/player_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4156,3 +4156,17 @@ int PlayerFunctions::luaPlayerKV(lua_State* L) {
setMetatable(L, -1, "KV");
return 1;
}

int PlayerFunctions::luaPlayerTakeScreenshot(lua_State* L) {
// player:takeScreenshot(screenshotType)
std::shared_ptr<Player> player = getUserdataShared<Player>(L, 1);
luanluciano93 marked this conversation as resolved.
Show resolved Hide resolved
if (!player) {
lua_pushnil(L);
return 1;
}

auto screenshotType = getNumber<uint8_t>(L, 2);
player->sendTakeScreenshot(screenshotType);
pushBoolean(L, true);
return 1;
}
4 changes: 4 additions & 0 deletions src/lua/functions/creatures/player/player_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ class PlayerFunctions final : LuaScriptInterface {

registerMethod(L, "Player", "kv", PlayerFunctions::luaPlayerKV);

registerMethod(L, "Player", "takeScreenshot", PlayerFunctions::luaPlayerTakeScreenshot);
luanluciano93 marked this conversation as resolved.
Show resolved Hide resolved

GroupFunctions::init(L);
GuildFunctions::init(L);
MountFunctions::init(L);
Expand Down Expand Up @@ -706,5 +708,7 @@ class PlayerFunctions final : LuaScriptInterface {

static int luaPlayerKV(lua_State* L);

static int luaPlayerTakeScreenshot(lua_State* L);
luanluciano93 marked this conversation as resolved.
Show resolved Hide resolved

friend class CreatureFunctions;
};
11 changes: 11 additions & 0 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8578,3 +8578,14 @@ void ProtocolGame::parseSaveWheel(NetworkMessage &msg) {

addGameTask(&Game::playerSaveWheel, player->getID(), msg);
}

void ProtocolGame::takeScreenshot(uint8_t screenshotType) {
luanluciano93 marked this conversation as resolved.
Show resolved Hide resolved
if (!player || oldProtocol) {
return;
}

NetworkMessage msg;
msg.addByte(0x75);
msg.addByte(screenshotType);
writeToOutputBuffer(msg);
}
2 changes: 2 additions & 0 deletions src/server/network/protocol/protocolgame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ class ProtocolGame final : public Protocol {
void sendSingleSoundEffect(const Position &pos, SoundEffect_t id, SourceEffect_t source);
void sendDoubleSoundEffect(const Position &pos, SoundEffect_t mainSoundId, SourceEffect_t mainSource, SoundEffect_t secondarySoundId, SourceEffect_t secondarySource);

void sendTakeScreenshot(uint8_t screenshotType);

uint8_t m_playerDeathTime = 0;

void resetPlayerDeathTime() {
Expand Down