mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-07-08 14:37:09 -04:00
Impl editor object names
This commit is contained in:
@@ -24,6 +24,7 @@ public:
|
||||
/* 0x24 */ Vec3f Velocity = {0, 0, 0};
|
||||
/* 0x30 */ Collision Unk30;
|
||||
uint8_t uuid[16];
|
||||
const char* Name = "";
|
||||
|
||||
Gfx* Model = NULL;
|
||||
|
||||
|
||||
@@ -116,6 +116,11 @@ void World::PreviousCourse() {
|
||||
AActor* World::AddActor(AActor* actor) {
|
||||
Actors.push_back(actor);
|
||||
|
||||
if (actor->Model != NULL) {
|
||||
gEditor.AddObject(actor->Name, (FVector*) &actor->Pos, (Gfx*)LOAD_ASSET_RAW(actor->Model), 1.0f, CollisionType::VTX_INTERSECT, 0.0f, (int32_t*)&actor->Type, 0);
|
||||
} else {
|
||||
gEditor.AddObject(actor->Name, (FVector*) &actor->Pos, NULL, 1.0f, CollisionType::VTX_INTERSECT, 0.0f, (int32_t*)&actor->Type, 0);
|
||||
}
|
||||
return Actors.back();
|
||||
}
|
||||
|
||||
@@ -175,9 +180,9 @@ OObject* World::AddObject(OObject* object) {
|
||||
Object* cObj = &gObjectList[object->_objectIndex];
|
||||
|
||||
if (cObj->model != NULL) {
|
||||
gEditor.AddObject("", (FVector*) &cObj->origin_pos[0], (Gfx*)LOAD_ASSET_RAW(cObj->model), 1.0f, CollisionType::VTX_INTERSECT, 0.0f, &object->_objectIndex, -1);
|
||||
gEditor.AddObject(object->Name, (FVector*) &cObj->origin_pos[0], (Gfx*)LOAD_ASSET_RAW(cObj->model), 1.0f, CollisionType::VTX_INTERSECT, 0.0f, &object->_objectIndex, -1);
|
||||
} else {
|
||||
gEditor.AddObject("", (FVector*) &cObj->origin_pos[0], NULL, 1.0f, CollisionType::VTX_INTERSECT, 0.0f, &object->_objectIndex, -1);
|
||||
gEditor.AddObject(object->Name, (FVector*) &cObj->origin_pos[0], NULL, 1.0f, CollisionType::VTX_INTERSECT, 0.0f, &object->_objectIndex, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ void render_actor_banana(Camera*, float[4][4], struct BananaActor*);
|
||||
}
|
||||
|
||||
ABanana::ABanana(uint16_t playerId, const float pos[3], const s16 rot[3], const float velocity[3]) {
|
||||
Name = "Banana";
|
||||
// Initialize the BananaActor's position, rotation, and velocity
|
||||
std::copy(pos, pos + 3, Pos);
|
||||
//std::copy(rot, rot + 3, this->a.rot);
|
||||
|
||||
@@ -10,7 +10,6 @@ public:
|
||||
|
||||
// Constructor
|
||||
ABanana(uint16_t playerId, const float pos[3], const s16 rot[3], const float velocity[3]);
|
||||
|
||||
virtual ~ABanana() override = default;
|
||||
|
||||
// Virtual functions to be overridden by derived classes
|
||||
|
||||
@@ -15,6 +15,7 @@ extern f32 gKartGravityTable[];
|
||||
}
|
||||
|
||||
ACloud::ACloud(Vec3f pos) {
|
||||
Name = "Cloud";
|
||||
Pos[0] = pos[0];
|
||||
Pos[1] = pos[1];
|
||||
Pos[2] = pos[2];
|
||||
|
||||
@@ -18,6 +18,7 @@ extern f32 gKartGravityTable[];
|
||||
}
|
||||
|
||||
AFinishline::AFinishline(std::optional<FVector> pos) {
|
||||
Name = "Finishline";
|
||||
|
||||
if (pos.has_value()) {
|
||||
// Set spawn point to the provided position
|
||||
|
||||
@@ -10,6 +10,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
ATree::ATree(Vec3f pos, Gfx* displaylist, f32 drawDistance, f32 minDrawDistance, const char* tlut = nullptr) {
|
||||
Name = "Tree";
|
||||
Pos[0] = pos[0];
|
||||
Pos[1] = pos[1];
|
||||
Pos[2] = pos[2];
|
||||
|
||||
@@ -10,6 +10,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
AWarioSign::AWarioSign(Vec3f pos) {
|
||||
Name = "Wario Sign";
|
||||
Pos[0] = pos[0];
|
||||
Pos[1] = pos[1];
|
||||
Pos[2] = pos[2];
|
||||
|
||||
@@ -13,6 +13,7 @@ Vtx gBowserStatueVtx[717];
|
||||
Gfx gBowserStatueGfx[162];
|
||||
|
||||
ABowserStatue::ABowserStatue(FVector pos, ABowserStatue::Behaviour behaviour) {
|
||||
Name = "Bowser Statue";
|
||||
Pos = pos;
|
||||
ABowserStatue::Behaviour _behaviour = behaviour;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
AShip::AShip(FVector pos, AShip::Skin skin) {
|
||||
Name = "Ship";
|
||||
Spawn = pos;
|
||||
Spawn.y += 10;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
ASpaghettiShip::ASpaghettiShip(FVector pos) {
|
||||
Name = "Spaghetti Ship";
|
||||
Spawn = pos;
|
||||
Spawn.y += 10;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
AStarship::AStarship(FVector pos) {
|
||||
Name = "Starship";
|
||||
Spawn = pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,23 +88,22 @@ void Gizmo::Translate() {
|
||||
_selected->Pos->x = (cameras[0].pos[0] + _ray.x * PickDistance) + _cursorOffset.x;
|
||||
_selected->Pos->y = (cameras[0].pos[1] + _ray.y * PickDistance) + _cursorOffset.y;
|
||||
_selected->Pos->z = (cameras[0].pos[2] + _ray.z * PickDistance) + _cursorOffset.z;
|
||||
if (CVarGetInteger("gEditorSnapToGround", false) == true) {
|
||||
if (CVarGetInteger("gEditorSnapToGround", 0) == true) {
|
||||
_selected->Pos->y = SnapToSurface(_selected->Pos);
|
||||
}
|
||||
printf("TEST %f\n", _selected->Pos->y);
|
||||
break;
|
||||
case GizmoHandle::X_Axis:
|
||||
_selected->Pos->x = (cameras[0].pos[0] + _ray.x * length) + _cursorOffset.x;
|
||||
if (CVarGetInteger("gEditorSnapToGround", false) == true) {
|
||||
if (CVarGetInteger("gEditorSnapToGround", 0) == true) {
|
||||
_selected->Pos->y = SnapToSurface(_selected->Pos);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case GizmoHandle::Y_Axis:
|
||||
_selected->Pos->y = (cameras[0].pos[1] + _ray.y * length) + _cursorOffset.y;
|
||||
break;
|
||||
case GizmoHandle::Z_Axis:
|
||||
_selected->Pos->z = (cameras[0].pos[2] + _ray.z * length) + _cursorOffset.z;
|
||||
if (CVarGetInteger("gEditorSnapToGround", false) == true) {
|
||||
if (CVarGetInteger("gEditorSnapToGround", 0) == true) {
|
||||
_selected->Pos->y = SnapToSurface(_selected->Pos);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -19,7 +19,7 @@ const char* sBoardwalkTexList[] = { gTextureBat1, gTextureBat2, gTextureBat3, gT
|
||||
size_t OBat::_count = 0;
|
||||
|
||||
OBat::OBat(const FVector& pos, const FRotation& rot) {
|
||||
|
||||
Name = "Bat";
|
||||
find_unused_obj_index(&_objectIndex);
|
||||
|
||||
init_texture_object(_objectIndex, (uint8_t*)d_course_banshee_boardwalk_bat_tlut, sBoardwalkTexList, 0x20U,
|
||||
|
||||
@@ -30,6 +30,7 @@ extern s8 gPlayerCount;
|
||||
size_t OBombKart::_count = 0;
|
||||
|
||||
OBombKart::OBombKart(Vec3f pos, TrackWaypoint* waypoint, uint16_t waypointIndex, uint16_t state, f32 unk_3C) {
|
||||
Name = "Bomb Kart";
|
||||
_idx = _count;
|
||||
Vec3f _pos = {0, 0, 0};
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ extern "C" {
|
||||
size_t OBoos::_count = 0;
|
||||
|
||||
OBoos::OBoos(size_t numBoos, const IPathSpan& leftBoundary, const IPathSpan& active, const IPathSpan& rightBoundary) {
|
||||
Name = "Boos";
|
||||
// Max five boos allowed due to limited splines
|
||||
// D_800E5D9C
|
||||
if (numBoos > 10) {
|
||||
|
||||
@@ -17,6 +17,7 @@ extern "C" {
|
||||
size_t OChainChomp::_count = 0;
|
||||
|
||||
OChainChomp::OChainChomp() {
|
||||
Name = "Chain Chomp";
|
||||
_idx = _count;
|
||||
init_object(indexObjectList2[_count], 0);
|
||||
_objectIndex = indexObjectList2[_count];
|
||||
|
||||
@@ -18,6 +18,7 @@ extern Lights1 D_800E45C0[];
|
||||
}
|
||||
|
||||
OCheepCheep::OCheepCheep(const FVector& pos, CheepType type, IPathSpan span) {
|
||||
Name = "Cheep Cheep";
|
||||
_type = type;
|
||||
_spawnPos = pos;
|
||||
_span = span;
|
||||
|
||||
@@ -28,6 +28,7 @@ extern "C" {
|
||||
size_t OCrab::_count = 0;
|
||||
|
||||
OCrab::OCrab(const FVector2D& start, const FVector2D& end) {
|
||||
Name = "Crab";
|
||||
_idx = _count;
|
||||
_start = start;
|
||||
_end = end;
|
||||
|
||||
@@ -16,6 +16,7 @@ extern "C" {
|
||||
size_t OFlagpole::_count = 0;
|
||||
|
||||
OFlagpole::OFlagpole(const FVector& pos, s16 direction) {
|
||||
Name = "Flagpole";
|
||||
_idx = _count;
|
||||
_pos = pos;
|
||||
_direction = direction;
|
||||
|
||||
@@ -15,6 +15,7 @@ extern "C" {
|
||||
size_t OHedgehog::_count = 0;
|
||||
|
||||
OHedgehog::OHedgehog(const FVector& pos, const FVector2D& patrolPoint, s16 unk) {
|
||||
Name = "Hedgehog";
|
||||
_idx = _count;
|
||||
_pos = pos;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
OHotAirBalloon::OHotAirBalloon(const FVector& pos) {
|
||||
Name = "Hot Air Balloon";
|
||||
_pos = pos;
|
||||
|
||||
D_80165898 = 0;
|
||||
|
||||
@@ -37,6 +37,7 @@ extern s8 gPlayerCount;
|
||||
}
|
||||
|
||||
OLakitu::OLakitu(s32 playerId, LakituType type) {
|
||||
Name = "Lakitu";
|
||||
_playerId = playerId;
|
||||
|
||||
init_object(gIndexLakituList[playerId], (s32)type);
|
||||
|
||||
@@ -25,6 +25,7 @@ extern "C" {
|
||||
size_t OMole::_count = 0;
|
||||
|
||||
OMole::OMole(FVector pos, OMoleGroup* group) {
|
||||
Name = "Mole";
|
||||
_idx = _count;
|
||||
_group = group;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ class OObject {
|
||||
public:
|
||||
uint8_t uuid[16];
|
||||
Object o;
|
||||
const char* Name = "";
|
||||
bool PendingDestroy = false;
|
||||
s32 _objectIndex = -1;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ extern s8 gPlayerCount;
|
||||
|
||||
|
||||
OPenguin::OPenguin(Vec3f pos, u16 direction, PenguinType type, Behaviour behaviour) {
|
||||
Name = "Penguin";
|
||||
_type = type;
|
||||
_bhv = behaviour;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ extern Vec3s D_800E634C[];
|
||||
// };
|
||||
|
||||
OPodium::OPodium(const FVector& pos) {
|
||||
|
||||
Name = "Podium";
|
||||
_pos = pos;
|
||||
|
||||
find_unused_obj_index(&_podium1Index);
|
||||
|
||||
@@ -32,6 +32,7 @@ SplineData* D_800E633C[] = { &D_800E6034, &D_800E60F0, &D_800E61B4, &D_800E6280
|
||||
size_t OSeagull::_count = 0;
|
||||
|
||||
OSeagull::OSeagull(FVector pos) {
|
||||
Name = "Seagull";
|
||||
_idx = _count;
|
||||
_pos.x = pos.x;
|
||||
_pos.y = pos.y;
|
||||
|
||||
@@ -17,6 +17,7 @@ static const char* sSnowmanHeadList[] = { d_course_frappe_snowland_snowman_head
|
||||
size_t OSnowman::_count = 0;
|
||||
|
||||
OSnowman::OSnowman(const FVector& pos) {
|
||||
Name = "Snowman";
|
||||
_idx = _count;
|
||||
_pos = pos;
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ s16 D_800E597C[] = { 0x0000, 0x0000, 0x4000, 0x8000, 0x8000, 0xc000 };
|
||||
size_t OThwomp::_count = 0;
|
||||
|
||||
OThwomp::OThwomp(s16 x, s16 z, s16 direction, f32 scale, s16 behaviour, s16 primAlpha, u16 boundingBoxSize) {
|
||||
Name = "Thwomp";
|
||||
_idx = _count;
|
||||
_faceDirection = direction;
|
||||
_boundingBoxSize = boundingBoxSize;
|
||||
|
||||
@@ -21,6 +21,7 @@ extern "C" {
|
||||
#define DEGREES_FLOAT_TO_SHORT(Degrees) ((s16)((Degrees) * (0x8000 / 180.0f)))
|
||||
|
||||
OTrashBin::OTrashBin(const FVector& pos, const FRotation& rotation, f32 scale, OTrashBin::Behaviour bhv) {
|
||||
Name = "Trashbin";
|
||||
_pos = pos;
|
||||
_rot = rotation;
|
||||
_scale = scale;
|
||||
|
||||
@@ -21,6 +21,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
OTrophy::OTrophy(const FVector& pos, TrophyType trophy, Behaviour bhv) {
|
||||
Name = "Trophy";
|
||||
_trophy = trophy;
|
||||
_spawnPos = pos;
|
||||
_spawnPos.y += 16.0f; // Adjust the height so the trophy sits on the surface when positioned to 0,0,0
|
||||
|
||||
@@ -17,6 +17,7 @@ extern s8 gPlayerCount;
|
||||
size_t ABoat::_count = 0;
|
||||
|
||||
ABoat::ABoat(f32 speed, u32 waypoint) {
|
||||
Name = "Paddle Steam Boat";
|
||||
Path2D* temp_a2;
|
||||
u16 waypointOffset;
|
||||
Index = _count;
|
||||
|
||||
@@ -19,6 +19,7 @@ extern s8 gPlayerCount;
|
||||
size_t ABus::_count = 0;
|
||||
|
||||
ABus::ABus(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) {
|
||||
Name = "Bus";
|
||||
TrackWaypoint* temp_v0;
|
||||
u16 waypointOffset;
|
||||
s32 numWaypoints = gWaypointCountByPathIndex[0];
|
||||
|
||||
@@ -19,6 +19,7 @@ extern s8 gPlayerCount;
|
||||
size_t ACar::_count = 0;
|
||||
|
||||
ACar::ACar(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) {
|
||||
Name = "Car";
|
||||
TrackWaypoint* temp_v0;
|
||||
u16 waypointOffset;
|
||||
s32 numWaypoints = gWaypointCountByPathIndex[0];
|
||||
|
||||
@@ -19,6 +19,7 @@ extern s8 gPlayerCount;
|
||||
size_t ATankerTruck::_count = 0;
|
||||
|
||||
ATankerTruck::ATankerTruck(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) {
|
||||
Name = "Tanker Truck";
|
||||
TrackWaypoint* temp_v0;
|
||||
u16 waypointOffset;
|
||||
s32 numWaypoints = gWaypointCountByPathIndex[0];
|
||||
|
||||
@@ -25,6 +25,7 @@ extern "C" {
|
||||
size_t ATrain::_count = 0;
|
||||
|
||||
ATrain::ATrain(ATrain::TenderStatus tender, size_t numCarriages, f32 speed, uint32_t waypoint) {
|
||||
Name = "Train";
|
||||
u16 waypointOffset;
|
||||
TrainCarStuff* ptr1;
|
||||
Path2D* pos;
|
||||
|
||||
@@ -19,6 +19,7 @@ extern s8 gPlayerCount;
|
||||
size_t ATruck::_count = 0;
|
||||
|
||||
ATruck::ATruck(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) {
|
||||
Name = "Truck";
|
||||
TrackWaypoint* temp_v0;
|
||||
u16 waypointOffset;
|
||||
s32 numWaypoints = gWaypointCountByPathIndex[0];
|
||||
|
||||
+1
-1
@@ -661,7 +661,7 @@ void CM_CleanWorld(void) {
|
||||
for (auto& emitter : world->Emitters) {
|
||||
delete emitter;
|
||||
}
|
||||
|
||||
gEditor.ClearObjects();
|
||||
gWorldInstance.Actors.clear();
|
||||
gWorldInstance.Objects.clear();
|
||||
gWorldInstance.Emitters.clear();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
namespace EditorNamespace {
|
||||
|
||||
ContentBrowserWindow::~ContentBrowserWindow() {
|
||||
SPDLOG_TRACE("destruct editor window");
|
||||
SPDLOG_TRACE("destruct content browser window");
|
||||
}
|
||||
|
||||
void ContentBrowserWindow::DrawElement() {
|
||||
|
||||
@@ -17,18 +17,24 @@
|
||||
namespace EditorNamespace {
|
||||
|
||||
SceneExplorerWindow::~SceneExplorerWindow() {
|
||||
SPDLOG_TRACE("destruct editor window");
|
||||
SPDLOG_TRACE("destruct scene explorer window");
|
||||
}
|
||||
|
||||
void SceneExplorerWindow::DrawElement() {
|
||||
ImGui::Text("Scene");
|
||||
|
||||
int id = 0; // id for now because we don't have unique names atm
|
||||
size_t id = 0; // id for now because we don't have unique names atm
|
||||
for (auto& object : gEditor.eGameObjects) {
|
||||
std::string label = fmt::format("Object {}", id++);
|
||||
if (ImGui::Button(object.Name)) {
|
||||
// Convert const char* to std::string before formatting
|
||||
std::string objectName = object.Name ? object.Name : "Obj";
|
||||
|
||||
// Ensure unique label using index
|
||||
std::string label = fmt::format("{}##{}", objectName, id);
|
||||
|
||||
if (ImGui::Button(label.c_str())) {
|
||||
gEditor.SelectObjectFromSceneExplorer(&object);
|
||||
}
|
||||
id += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
-5
@@ -14,7 +14,7 @@
|
||||
namespace EditorNamespace {
|
||||
|
||||
ToolsWindow::~ToolsWindow() {
|
||||
SPDLOG_TRACE("destruct editor window");
|
||||
SPDLOG_TRACE("destruct tools window");
|
||||
}
|
||||
|
||||
void ToolsWindow::InitElement() {
|
||||
@@ -22,13 +22,14 @@ namespace EditorNamespace {
|
||||
}
|
||||
|
||||
void ToolsWindow::DrawElement() {
|
||||
static bool toggleState = false;
|
||||
static bool toggleState = CVarGetInteger("gEditorSnapToGround", 0);
|
||||
static int selectedTool = 0; // 0: Move, 1: Rotate, 2: Scale
|
||||
|
||||
|
||||
ImVec4 defaultColor = ImGui::GetStyle().Colors[ImGuiCol_Button];
|
||||
// Function to check and highlight the selected button
|
||||
auto ToolButton = [&](const char* label, int id) {
|
||||
bool isSelected = (selectedTool == id);
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, isSelected ? ImVec4(0.2f, 0.8f, 0.2f, 1.0f) : ImVec4(0.8f, 0.2f, 0.2f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, isSelected ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor);
|
||||
|
||||
if (ImGui::Button(label, ImVec2(125, 25))) {
|
||||
selectedTool = id; // Set the selected tool
|
||||
@@ -44,12 +45,24 @@ namespace EditorNamespace {
|
||||
ImGui::SameLine();
|
||||
ToolButton("Scale", 2);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, toggleState ? ImVec4(0.2f, 0.8f, 0.2f, 1.0f) : ImVec4(0.8f, 0.2f, 0.2f, 1.0f));
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, toggleState ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor);
|
||||
if (ImGui::Button(toggleState ? "SNAP TO GROUND" : "SNAP TO GROUND", ImVec2(125, 25))) {
|
||||
toggleState = !toggleState;
|
||||
|
||||
CVarSetInteger("gEditorSnapToGround", toggleState);
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Player One AI/Human", ImVec2(160, 25))) {
|
||||
if (gPlayerOne->type & PLAYER_KART_AI) {
|
||||
gPlayerOne->type &= ~PLAYER_KART_AI;
|
||||
} else {
|
||||
gPlayerOne->type |= PLAYER_KART_AI;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1066,15 +1066,6 @@ void spawn_course_actors(void) {
|
||||
|
||||
gNumPermanentActors = 0;
|
||||
|
||||
if (gModeSelection != BATTLE) {
|
||||
if (!CM_DoesFinishlineExist()) {
|
||||
printf("\n[actors.c] COURSE MISSING THE FINISHLINE\n");
|
||||
printf(" In the Course class BeginPlay() function make sure to include:\n");
|
||||
printf(" gWorldInstance.AddActor(new AFinishline());\n\n");
|
||||
printf("\n Otherwise, course textures may glitch out or other strange issues may occur.\n");
|
||||
}
|
||||
}
|
||||
|
||||
// switch (gCurrentCourseId) {
|
||||
// case COURSE_MARIO_RACEWAY:
|
||||
// // spawn_foliage(d_course_mario_raceway_tree_spawns);
|
||||
|
||||
Reference in New Issue
Block a user