v1.0
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { ArcHandles } from "Adornment/ArcHandles";
|
||||
import { doorAdornment } from "Adornment/Exit";
|
||||
import { Handles } from "Adornment/Handles";
|
||||
import CollapsibleTitledSection from "Lualibs/CollapsibleTitledSection";
|
||||
import CustomTextButton from "Lualibs/CustomTextButton";
|
||||
import LabeledTextInput from "Lualibs/LabeledTextInput";
|
||||
@@ -22,7 +25,7 @@ export class RoomWidget {
|
||||
true, // minimizable?
|
||||
false, // minimized by default?
|
||||
);
|
||||
exitCollapse = new CollapsibleTitledSection(
|
||||
exitsCollapse = new CollapsibleTitledSection(
|
||||
"ExitCollapse", // name suffix of the gui object
|
||||
"Exit", // title text of the collapsible arrow
|
||||
true, // have the content frame auto-update its size?
|
||||
@@ -72,7 +75,7 @@ export class RoomWidget {
|
||||
const typeTextBox = this.roomTypeInput.GetFrame().FindFirstChildWhichIsA("TextBox", true)!;
|
||||
typeTextBox.ClearTextOnFocus = false;
|
||||
this.listFrame.AddChild(this.roomCollapse.GetSectionFrame());
|
||||
this.listFrame.AddChild(this.exitCollapse.GetSectionFrame());
|
||||
this.listFrame.AddChild(this.exitsCollapse.GetSectionFrame());
|
||||
|
||||
this.listFrame.AddBottomPadding();
|
||||
|
||||
@@ -85,32 +88,101 @@ export class RoomWidget {
|
||||
this.roomIdInput.SetValue(tostring(config.RoomId.Value));
|
||||
this.roomTypeValue = config.RoomType;
|
||||
this.roomTypeInput.SetValue(config.RoomType.Value);
|
||||
|
||||
const exits = config
|
||||
.GetChildren()
|
||||
.filter(
|
||||
(value) => !string.match(value.Name, "^Exit_[0-9]+$").isEmpty() && value.IsA("CFrameValue"),
|
||||
) as CFrameValue[];
|
||||
|
||||
this.ReloadExits(exits, config);
|
||||
}
|
||||
SetActive(active: boolean) {
|
||||
this.noRoomLabel.Visible = !active;
|
||||
}
|
||||
ReloadExits(exits: CFrameValue[]) {
|
||||
this.exitCollapse.GetContentsFrame().ClearAllChildren();
|
||||
ReloadExits(exits: CFrameValue[], config: RoomConfig) {
|
||||
this.exitsCollapse.GetContentsFrame().ClearAllChildren();
|
||||
|
||||
const exitListFrame = new VerticallyScalingListFrame("RoomWidget");
|
||||
|
||||
for (const exit of exits) {
|
||||
const exitCollapse = new CollapsibleTitledSection(
|
||||
"ExitCollapse_" + exit.Name, // name suffix of the gui object
|
||||
exit.Name, // the text displayed beside the collapsible arrow
|
||||
true, // have the content frame auto-update its size?
|
||||
true, // minimizable?
|
||||
false, // minimized by default?
|
||||
);
|
||||
|
||||
const button = new CustomTextButton(
|
||||
const posbutton = new CustomTextButton(
|
||||
"edit_button", // name of the gui object
|
||||
"Edit", // the text displayed on the button
|
||||
`Edit ${exit.Name} position`, // the text displayed on the button
|
||||
);
|
||||
(button.GetButton() as ImageButton).Activated.Connect(() => {
|
||||
|
||||
const posbuttonobject = posbutton.GetButton() as ImageButton;
|
||||
posbuttonobject.Activated.Connect(() => {
|
||||
this.LoadExitMoveHandles(exit);
|
||||
});
|
||||
posbuttonobject.Size = new UDim2(0, 150, 0, 20);
|
||||
|
||||
// Handle widget
|
||||
exitCollapse.GetContentsFrame().Parent = this.exitCollapse.GetSectionFrame();
|
||||
const rotbutton = new CustomTextButton(
|
||||
"edit_button", // name of the gui object
|
||||
`Edit ${exit.Name} rotation`, // the text displayed on the button
|
||||
);
|
||||
const rotbuttonobject = rotbutton.GetButton() as ImageButton;
|
||||
rotbuttonobject.Activated.Connect(() => {
|
||||
this.LoadExitRotationHandles(exit);
|
||||
});
|
||||
rotbuttonobject.Size = new UDim2(0, 150, 0, 20);
|
||||
|
||||
exitListFrame.AddChild(posbuttonobject);
|
||||
exitListFrame.AddChild(rotbuttonobject);
|
||||
}
|
||||
|
||||
const rotbutton = new CustomTextButton(
|
||||
"create_button", // name of the gui object
|
||||
`Create a Exit`, // the text displayed on the button
|
||||
);
|
||||
const createbutobject = rotbutton.GetButton() as ImageButton;
|
||||
createbutobject.Activated.Connect(() => {
|
||||
const exit = new Instance("CFrameValue");
|
||||
exit.Parent = config;
|
||||
exit.Value = new CFrame(config.Origin.Value);
|
||||
exit.Name = `Exit_${exits.size()}`;
|
||||
exits.push(exit);
|
||||
this.ReloadExits(exits, config);
|
||||
});
|
||||
createbutobject.Size = new UDim2(0, 150, 0, 20);
|
||||
exitListFrame.AddChild(createbutobject);
|
||||
|
||||
exitListFrame.AddBottomPadding();
|
||||
exitListFrame.GetFrame().Parent = this.exitsCollapse.GetContentsFrame();
|
||||
}
|
||||
LoadExitMoveHandles(exit: CFrameValue) {
|
||||
this.clearExitHandles();
|
||||
|
||||
const folder = new Instance("Folder");
|
||||
folder.Parent = this.model;
|
||||
folder.Name = "_exit_handle";
|
||||
|
||||
const exithandle = new Handles(folder, exit.Value.Position);
|
||||
exithandle.valueChanged.Connect((value) => {
|
||||
const oldvalue = exit.Value;
|
||||
exit.Value = new CFrame(value).mul(oldvalue.sub(oldvalue.Position));
|
||||
});
|
||||
doorAdornment(folder, exithandle.anchor);
|
||||
}
|
||||
LoadExitRotationHandles(exit: CFrameValue) {
|
||||
this.clearExitHandles();
|
||||
|
||||
const folder = new Instance("Folder");
|
||||
folder.Parent = this.model;
|
||||
folder.Name = "_exit_handle";
|
||||
|
||||
const exithandle = new ArcHandles(folder, exit.Value);
|
||||
exithandle.valueChanged.Connect((value) => {
|
||||
const oldvalue = exit.Value;
|
||||
exit.Value = new CFrame(oldvalue.Position).mul(value.Rotation);
|
||||
});
|
||||
doorAdornment(folder, exithandle.anchor);
|
||||
}
|
||||
clearExitHandles() {
|
||||
const childs = this.model.GetChildren();
|
||||
childs
|
||||
.filter((value) => value.Name === "_exit_handle")
|
||||
.forEach((value) => {
|
||||
value.Destroy();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user