Skip to content

Commit

Permalink
added support for sergey head, fixes potential item spawner crash
Browse files Browse the repository at this point in the history
  • Loading branch information
elluminance committed Feb 10, 2024
1 parent 2359d01 commit 891eb45
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 49 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Once you have favorited a quest, you can cycle through them just like you would
* **Ball Autofiring**: By holding the `F` key, you can automatically fire balls using mouse and keyboard - something previously exclusive to controller controls. (***NOTE***: requires [input-api](https://github.com/CCDirectLink/input-api) to function properly.)
* **Custom Map Name Fix**: Fixes custom mod map/area names as sometimes being displayed as `[object Object]` in save slots.
* **Arena Ascended Gear Scaling**: Fixes the ascended gear scaling modifier for arena cups/rounds to actually work properly for individual rounds (and not erroneously apply to some cups which might lack the scaling)
* **Icon Fix** One DLC-only character lacks a proper head icon and just displays as `<?>`. If

---
# For Modders
Expand Down
11 changes: 11 additions & 0 deletions assets/data/players/headIdx.json.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[{
"type": "ENTER",
"index": "headIdx"
},{
"type": "ADD_ARRAY_ELEMENT",
"content": {
"id": "main.sergey-av",
"img": "media/gui/severed-heads/sergey-av.png",
"name": "sergey-av"
}
}]
Binary file added assets/media/gui/severed-heads/sergey-av.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions ccmod.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"id": "el-tweaks",
"version": "0.7.4",
"version": "0.7.5",

"title": "EL's Tweaks",
"description": "A coremod full of useful functionality for modders, as well as many tweaks for players.",

"plugin": "./dist/plugin.js"
"plugin": "./dist/plugin.js",

"dependencies": {
"ccloader": "2.x.x"
}
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "el-tweaks",
"displayName": "EL's Tweaks",
"version": "0.7.4",
"version": "0.7.5",
"description": "A coremod full of useful functionality for modders, as well as many tweaks for players.",

"plugin": "./dist/plugin.js",

"ccmodDependencies": {},
"ccmodDependencies": {
"ccloader": "2.x.x"
},

"devDependencies": {
"typescript": "5.1.6",
Expand Down
Binary file added readme-imgs/sergey-head.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 32 additions & 21 deletions src/headers/other-mods.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
declare namespace ig {
/*
* While this is disingenuous of the input field's type...
* The point is not to make it accurate.
* It's to make it provide a minimum needed interface for the item spawner.
*
*/
namespace GuiTextInputField {
interface InputFieldType {}
import * as semver from "../../node_modules/ultimate-crosscode-typedefs/semver-ext";

export {};

declare global {
interface Window {
semver: typeof semver;
}
interface GuiTextInputField extends ig.FocusGui {
onCharacterInput: () => void;
getValueAsString(this: this): string;
namespace ig {
/*
* While this is disingenuous of the input field's type...
* The point is not to make it accurate.
* It's to make it provide a minimum needed interface for the item spawner.
*
*/
namespace GuiTextInputField {
interface InputFieldType {}
}
interface GuiTextInputField extends ig.FocusGui {
onCharacterInput: () => void;
getValueAsString(this: this): string;
}
interface GuiTextInputFieldConstructor extends ImpactClass<GuiTextInputField> {
new (width: number, height: number): GuiTextInputField
}
var GuiTextInputField: GuiTextInputFieldConstructor | undefined;
}
interface GuiTextInputFieldConstructor extends ImpactClass<GuiTextInputField> {
new (width: number, height: number): GuiTextInputField

namespace nax.ccuilib {
type InputField = ig.GuiTextInputField;
type InputFieldConstructor = ig.GuiTextInputFieldConstructor;
let InputField: InputFieldConstructor | undefined;
}
var GuiTextInputField: GuiTextInputFieldConstructor | undefined;
}

declare namespace nax.ccuilib {
type InputField = ig.GuiTextInputField;
type InputFieldConstructor = ig.GuiTextInputFieldConstructor;
let InputField: InputFieldConstructor | undefined;
}


28 changes: 5 additions & 23 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Mod, LegacyPluginClass } from "../node_modules/ultimate-crosscode-typedefs/modloader/mod";
import type { Mod, PluginClass } from "../node_modules/ultimate-crosscode-typedefs/modloader/mod";

const verRegex = /^v?(\d)\.(\d)\.(\d)(?:-(\d))?$/

export default class implements LegacyPluginClass {
export default class implements PluginClass {
constructor(public mod: Mod) {};

preload() {
Expand All @@ -11,29 +11,11 @@ export default class implements LegacyPluginClass {
}

prestart() {

el.isCCVersionAtLeast = verString => {
let match = verString.match(verRegex);
if(!match) return false;
let major = +match[1];
let minor = +match[2];
let patch = +match[3];
let hotfix = +match[4] || 0;
let ccver = `${sc.version.major}.${sc.version.minor}.${sc.version.patch}-${sc.version.hotfix}`;

if(major < sc.version.major) {
return true;
} else if (major == sc.version.major) {
if (minor < sc.version.minor) {
return true;
} else if (minor == sc.version.minor) {
if(patch < sc.version.patch)
return true;
else if (patch == sc.version.patch) {
return hotfix <= sc.version.hotfix;
}
}
}

return false;
return window.semver.gte(verString, ccver);
}

import("./prestart/prestart.js");
Expand Down
6 changes: 6 additions & 0 deletions src/poststart/misc/modutils-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ window.cmd = {
ig.vars.storage.tmp = {};
ig.game.varsChangedDeferred();
},

changePlayerConfig(name: string) {
if(sc.PARTY_OPTIONS.includes(name)) {
sc.model.player.setConfig(sc.party.models[name].config)
}
}
}
7 changes: 7 additions & 0 deletions src/prestart/game/player-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@ sc.PlayerConfig.inject({
if(this.name === sc.model?.player.config.name) {
sc.model.player.setConfig(this);
}

// this is so there's no issues with not having the proper head
// if extendable-severed-heads is not installed.
if(this.name == "Sergey" && window.semver.satisfies(window.versions["extendable-severed-heads"], ">=1.1.0")) {
//@ts-expect-error
this.headIdx = "sergey-av";
}
}
})
2 changes: 1 addition & 1 deletion src/prestart/menu/item-spawner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ el.ItemSpawnerGui = sc.ModalButtonInteract.extend({
this.filterButtongroup = new sc.ButtonGroup;


let textInput = nax.ccuilib.InputField || ig.GuiTextInputField;
let textInput = window.nax?.ccuilib?.InputField || ig.GuiTextInputField;

if(textInput) {
this.searchActive = true;
Expand Down

0 comments on commit 891eb45

Please sign in to comment.