Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ccmod.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"open-world": ">=0.5.6",
"nax-ccuilib": ">=1.5.1",
"tips-and-tricks": ">=0.1.0",
"ccmodmanager": ">=1.0.4",
"ccmodmanager": ">=1.2.1",
"font-utils": ">=1.2.0"
}
}
53 changes: 51 additions & 2 deletions src/patches/gui-misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ declare global {
AP_CONNECTION,
}

interface APUpDownInputField extends modmanager.gui.InputField {
tabDirection: "right" | "down";
maxLength: number;
onEnterPressedCallback?: (this: this) => void;
}

interface APUpDownInputFieldConstructor extends ImpactClass<APUpDownInputField> {
new (
width: number,
height: number,
type?: modmanager.gui.InputFieldType,
obscure?: boolean,
obscureChar?: string
): modmanager.gui.InputField;
}

var APUpDownInputField: APUpDownInputFieldConstructor;

interface APOptionGroup extends ig.GuiElementBase {
value: string;
buttons: Array<sc.ButtonGui>,
Expand Down Expand Up @@ -85,6 +103,37 @@ export function patch(plugin: MwRandomizer) {
}
});

sc.APUpDownInputField = modmanager.gui.InputField.extend({
tabDirection: "down",
maxLength: 100,
processInput(event) {
event.preventDefault();
if (event.key == "Enter") {
this.onEnterPressedCallback?.();
} else if (event.key == "ArrowDown") {
this.buttonGroup.stepDown();
} else if (event.key == "ArrowUp") {
this.buttonGroup.stepUp();
} else if (event.key == "Tab") {
if (this.tabDirection == 'down') {
if (event.shiftKey) {
this.buttonGroup.stepUp();
} else {
this.buttonGroup.stepDown();
}
} else {
if (event.shiftKey) {
this.buttonGroup.stepLeft();
} else {
this.buttonGroup.stepRight();
}
}
} else {
this.parent(event);
}
},
});

sc.APOptionGroup = ig.GuiElementBase.extend({
buttons: [],
value: "",
Expand Down Expand Up @@ -311,9 +360,9 @@ export function patch(plugin: MwRandomizer) {
let inputGui;
switch (this.fields[i].type) {
case "INPUT":
inputGui = new modmanager.gui.InputField(
inputGui = new sc.APUpDownInputField(
200,
textGui.hook.size.y,
textGui.hook.size.y + 3,
modmanager.gui.INPUT_FIELD_TYPE.DEFAULT,
this.fields[i].obscure ?? false
);
Expand Down
30 changes: 18 additions & 12 deletions src/patches/text-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ declare global {
list: sc.APMessageList;

scroll(this: this, amount: number): void;
scrollToBottom(this: this): void;
scrollToTop(this: this): void;
scrollToBottom(this: this, skip?: boolean): void;
scrollToTop(this: this, skip?: boolean): void;

addMessage(this: this, message: ap.MessageNode[]): sc.APMessageList.MessageEntry;
}
Expand Down Expand Up @@ -278,6 +278,10 @@ export function patch(plugin: MwRandomizer) {
},

recalculateRenderWindow(direction, startIndex) {
if (this.allMessages.length == 0) {
return;
}

if (direction == undefined) {
direction = 1;
}
Expand Down Expand Up @@ -355,15 +359,15 @@ export function patch(plugin: MwRandomizer) {
this.list.scroll(amount);
},

scrollToBottom() {
scrollToBottom(skip) {
let target = this.list.hook.size.y - this.list.viewportHeight;
this.scrollBox.setScrollY(target);
this.scrollBox.setScrollY(target, skip);
this.list.viewportPos = target;
this.list.recalculateRenderWindow(-1);
},

scrollToTop() {
this.scrollBox.setScrollY(0);
scrollToTop(skip) {
this.scrollBox.setScrollY(0, skip);
this.list.viewportPos = 0;
this.list.recalculateRenderWindow(1);
},
Expand Down Expand Up @@ -419,6 +423,7 @@ export function patch(plugin: MwRandomizer) {
this.console = new sc.APConsole(400, 260, this.list);
this.console.hook.pos.x = 15;
this.console.hook.pos.y = 30;
this.console.scrollToBottom(true);
this.addChildGui(this.console);

this.console.doStateTransition("HIDDEN", true);
Expand Down Expand Up @@ -504,10 +509,10 @@ export function patch(plugin: MwRandomizer) {
this.console.scroll(-this.list.viewportHeight + 10);
} else if (ig.input.pressed("pgdn")) {
this.console.scroll(this.list.viewportHeight - 10);
} else if (ig.input.pressed("home")) {
this.console.scrollToTop();
} else if (ig.input.pressed("end")) {
this.console.scrollToBottom();
} else if (ig.input.pressed("home") || ig.gamepad.isButtonPressed(ig.BUTTONS.LEFT_SHOULDER)) {
this.console.scrollToTop(true);
} else if (ig.input.pressed("end") || ig.gamepad.isButtonPressed(ig.BUTTONS.RIGHT_SHOULDER)) {
this.console.scrollToBottom(true);
}

if (sc.control.menuScrollUp()) {
Expand All @@ -516,9 +521,10 @@ export function patch(plugin: MwRandomizer) {
this.console.scroll(40);
}

let axes = ig.gamepad.getAxesValue(ig.AXES.RIGHT_STICK_Y, true)
let speedup = ig.gamepad.isButtonDown(ig.BUTTONS.RIGHT_TRIGGER);
let axes = ig.gamepad.getAxesValue(ig.AXES.RIGHT_STICK_Y, true);
if (Math.abs(axes) != 0) {
this.console.scroll(600 * axes * ig.system.tick);
this.console.scroll(600 * axes * ig.system.tick * (speedup ? 3 : 1));
}
},

Expand Down