Skip to content

Commit

Permalink
[Scripting] fix Screen constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Imrglop committed Nov 30, 2024
1 parent 5581fe4 commit 2703c13
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/client/screen/script/JsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "sdk/common/client/gui/controls/VisualTree.h"
#include "sdk/common/client/gui/controls/UIControl.h"

JsScreen::JsScreen(JsValueRef object, JsValueRef renderFunc) : renderFunc(renderFunc) {
JsScreen::JsScreen(JsValueRef object, std::string name) : name(std::move(name)) {
JS::JsGetCurrentContext(&this->ctx);

Chakra::GetStringProperty(object, L"name");
Expand Down
3 changes: 1 addition & 2 deletions src/client/screen/script/JsScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class JsScreen : public Screen, public JsEvented {
public:
JsScreen(JsValueRef object, JsValueRef renderFunc);
JsScreen(JsValueRef object, std::string name);

void onRender(class ::Event& ev);
void onKey(::Event& ev);
Expand All @@ -25,7 +25,6 @@ class JsScreen : public Screen, public JsEvented {
void onDisable() override;
private:
JsValueRef object = JS_INVALID_REFERENCE;
JsValueRef renderFunc = JS_INVALID_REFERENCE;
JsContextRef ctx = JS_INVALID_REFERENCE;

std::string name;
Expand Down
6 changes: 3 additions & 3 deletions src/client/script/class/impl/JsScreenClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class JsScreenClass : public JsWrapperClass<JsScreen> {
static JsValueRef CALLBACK jsConstructor(JsValueRef callee, bool isConstructor,
JsValueRef* arguments, unsigned short argCount, void* callbackState) {
auto thi = reinterpret_cast<JsScreenClass*>(callbackState);
if (!Chakra::VerifyArgCount(argCount, 2)) return JS_INVALID_REFERENCE;
if (!Chakra::VerifyParameters({ {arguments[1], JsString}, {arguments[2], JsFunction} })) return JS_INVALID_REFERENCE;
if (!Chakra::VerifyArgCount(argCount, 1)) return JS_INVALID_REFERENCE;
if (!Chakra::VerifyParameters({ {arguments[1], JsString} })) return JS_INVALID_REFERENCE;

auto screen = new JsScreen(arguments[0], arguments[2]);
auto screen = new JsScreen(arguments[0], util::WStrToStr(Chakra::GetString(arguments[1])));
JsValueRef obj = thi->construct(screen, false);
return obj;
}
Expand Down

0 comments on commit 2703c13

Please sign in to comment.