Skip to content

Commit

Permalink
Merge pull request #38 from Chubbygummibear/see-invis-setting
Browse files Browse the repository at this point in the history
Adds a context menu for changing the see_invisibility of the viewer from the options
  • Loading branch information
monster860 authored Nov 11, 2023
2 parents b33bbfa + a10c088 commit 477aafb
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
28 changes: 27 additions & 1 deletion src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DemoPlayerUi } from "./ui";
import classes from "./menu.scss";
import { InspectorPanel } from "./inspector";
import { ChatPanel } from "./chat";
import { SeeInvisibility } from "../misc/constants";

export class Menu extends Panel {
constructor() {
Expand Down Expand Up @@ -74,10 +75,13 @@ export class MainMenu extends Menu {
this.ui.nerdy_stats.style.display = (this.ui.nerdy_stats.style.display == "block") ? "none" : "block";
this.close();
});
let vision_button = this.add_basic_button("Set Vision", null, () => {
new SeeInvisibilityMenu(this.ui).put_to_right(vision_button).open(true);
});
this.add_basic_button("Toggle Darkness", null, () => {
this.ui.player.toggle_darkness();
this.close();
})
});
}
}

Expand Down Expand Up @@ -237,3 +241,25 @@ export class ChatOptionsMenu extends Menu {
});
}
}

///For setting the see_invisibility value of the demo player
export class SeeInvisibilityMenu extends Menu {
constructor(public ui : DemoPlayerUi) {
super();
this.add_basic_button("Minimum Possible Vision", null, () => {
ui.player.set_see_invisible(SeeInvisibility.SEE_INVISIBLE_MINIMUM);
});
this.add_basic_button("Regular Vision", null, () => {
ui.player.set_see_invisible(SeeInvisibility.SEE_INVISIBLE_LIVING);
});
this.add_basic_button("Ghost vision", null, () => {
ui.player.set_see_invisible(SeeInvisibility.SEE_INVISIBLE_OBSERVER);
});
this.add_basic_button("ALL vision", null, () => {
ui.player.set_see_invisible(SeeInvisibility.INVISIBILITY_MAXIMUM);
});
this.add_basic_button("Debug vision", null, () => {
ui.player.set_see_invisible(SeeInvisibility.INVISIBILITY_ABSTRACT);
});
}
}
8 changes: 8 additions & 0 deletions src/misc/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ export const SOUND_STREAM = 4;
export const SOUND_UPDATE = 16;

export const MAX_LAYER : number = 32;

export const enum SeeInvisibility{
SEE_INVISIBLE_MINIMUM = 5,
SEE_INVISIBLE_LIVING = 25,
SEE_INVISIBLE_OBSERVER = 60,
INVISIBILITY_MAXIMUM = 100,
INVISIBILITY_ABSTRACT = 101,
}
17 changes: 14 additions & 3 deletions src/player/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AtlasNode, DmiAtlas } from "./rendering/atlas";
import { IconState, IconStateDir } from "./rendering/icon";
import { CmdViewport, FollowDesc, RenderingCmd } from "./rendering/commands";
import { DrawBuffer } from "./rendering/buffer";
import { LONG_GLIDE, RESET_ALPHA, RESET_COLOR, RESET_TRANSFORM, SEE_MOBS, SEE_OBJS, SEE_THRU, SEE_TURFS } from "../misc/constants";
import { LONG_GLIDE, RESET_ALPHA, RESET_COLOR, RESET_TRANSFORM, SEE_MOBS, SEE_OBJS, SEE_THRU, SEE_TURFS, SeeInvisibility } from "../misc/constants";
import { matrix_is_identity, matrix_multiply } from "../misc/matrix";
import { despam_promise } from "../misc/promise_despammer";
import { view_turfs } from "./view";
Expand Down Expand Up @@ -44,7 +44,8 @@ export class DemoPlayer {
icon_loader : IconLoader;

z_level = 2;
use_index=0;
use_index = 0;
see_invisible = SeeInvisibility.SEE_INVISIBLE_OBSERVER;

change_counter = 0;

Expand Down Expand Up @@ -334,7 +335,7 @@ export class DemoPlayer {
height: d_turf_window.top - d_turf_window.bottom
}
});
this.draw_object_list(drawing_commands, objects, undefined, followview_window);
this.draw_object_list(drawing_commands, objects, this.see_invisible, followview_window);
drawing_commands.push({cmd: "copytoviewport", follow_data, followview_window});
this.last_objects = objects;

Expand Down Expand Up @@ -965,6 +966,16 @@ export class DemoPlayer {
this.show_darkness = !this.show_darkness;
this.change_counter++;
}

/**
* Adjust the see_invisibility that you can see on the replay viewer through the vision menu. Invisibility flags is how some objects and items are invisible
to mobs. Like regular living players not being able to see ghosts, or cables under floor tiles
* @param vision_setting a number to determine the sight flag for the viewer. the SeeInvisibility enum has all the relevant vision flag settings
*/
set_see_invisible(vision_setting: number = SeeInvisibility.SEE_INVISIBLE_OBSERVER) {
this.see_invisible = vision_setting;
this.change_counter++;
}
}

export abstract class Renderable {
Expand Down

0 comments on commit 477aafb

Please sign in to comment.