Skip to content

Commit

Permalink
mark isRoofOpened and setRoofOpened as deprecated
Browse files Browse the repository at this point in the history
Former-commit-id: eeba229
  • Loading branch information
martonp96 committed Dec 19, 2020
1 parent c5fd4cd commit b7c0a2c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/bindings/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ extern V8Class v8Vehicle("Vehicle", v8Entity, Constructor, [](v8::Local<v8::Func
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "daylightOn"), &DaylightOnGetter);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "nightlightOn"), &NightlightOnGetter);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "roofState"), &RoofStateGetter, &RoofStateSetter);

proto->Set(v8::String::NewFromUtf8(isolate, "isRoofOpened"), v8::FunctionTemplate::New(isolate, &IsRoofOpenedDeprecated));
proto->Set(v8::String::NewFromUtf8(isolate, "setRoofOpened"), v8::FunctionTemplate::New(isolate, &SetRoofOpenedDeprecated));

proto->SetAccessor(v8::String::NewFromUtf8(isolate, "flamethrowerActive"), &FlamethrowerActiveGetter);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "activeRadioStation"), &ActiveRadioStationGetter, &ActiveRadioStationSetter);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "lightsMultiplier"), &LightsMultiplierGetter, &LightsMultiplierSetter);
Expand Down
36 changes: 34 additions & 2 deletions src/bindings/vehicle/GameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ namespace V8::Vehicle

Ref<IVehicle> vehicle = _this->GetHandle().As<IVehicle>();

info.GetReturnValue().Set(v8::Boolean::New(isolate, vehicle->GetRoofState()));
info.GetReturnValue().Set(v8::Integer::New(isolate, vehicle->GetRoofState()));
}

void RoofStateSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
Expand All @@ -224,7 +224,39 @@ namespace V8::Vehicle

Ref<IVehicle> vehicle = _this->GetHandle().As<IVehicle>();

vehicle->SetRoofState(value->ToBoolean(info.GetIsolate())->Value());
vehicle->SetRoofState(value->ToInteger(info.GetIsolate())->Value());
}

void IsRoofOpenedDeprecated(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();

V8ResourceImpl* resource = V8ResourceImpl::Get(isolate->GetEnteredContext());
V8_CHECK(resource, "invalid resource");

V8Entity* _this = V8Entity::Get(info.This());
V8_CHECK(_this, "entity is invalid");

Ref<IVehicle> vehicle = _this->GetHandle().As<IVehicle>();

info.GetReturnValue().Set(v8::Boolean::New(isolate, vehicle->GetRoofState()));
}

void SetRoofOpenedDeprecated(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();

V8_CHECK(info.Length() == 1, "1 arg expected");

V8ResourceImpl* resource = V8ResourceImpl::Get(isolate->GetEnteredContext());
V8_CHECK(resource, "invalid resource");

V8Entity* _this = V8Entity::Get(info.This());
V8_CHECK(_this, "entity is invalid");

Ref<IVehicle> vehicle = _this->GetHandle().As<IVehicle>();

vehicle->SetRoofState(info[0]->ToInteger(isolate)->Value());
}

void FlamethrowerActiveGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
Expand Down

0 comments on commit b7c0a2c

Please sign in to comment.