Skip to content

Commit

Permalink
Further cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
luxaritas committed Jan 20, 2022
1 parent 5fc539b commit 7391922
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 82 deletions.
45 changes: 5 additions & 40 deletions src/eterna/mode/GameMode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as log from 'loglevel';
import {Container, Point, Text} from 'pixi.js';
import {Container, Text} from 'pixi.js';
import Eterna from 'eterna/Eterna';
import UndoBlock, {TargetConditions} from 'eterna/UndoBlock';
import SecStruct from 'eterna/rnatypes/SecStruct';
Expand All @@ -19,7 +19,7 @@ import ContextMenu from 'eterna/ui/ContextMenu';
import URLButton from 'eterna/ui/URLButton';
import EternaURL from 'eterna/net/EternaURL';
import Folder from 'eterna/folding/Folder';
import Dialog from 'eterna/ui/Dialog';
import ContextMenuDialog from 'eterna/ui/ContextMenuDialog';
import Utility from 'eterna/util/Utility';
import PasteSequenceDialog from 'eterna/ui/PasteSequenceDialog';
import NucleotideFinder from 'eterna/ui/NucleotideFinder';
Expand Down Expand Up @@ -335,9 +335,6 @@ export default abstract class GameMode extends AppMode {
public onContextMenuEvent(e: Event): void {
Assert.assertIsDefined(Flashbang.globalMouse);

let pos = Flashbang.globalMouse;
const ee = <PointerEvent> e;
if (ee.clientX !== undefined && ee.clientY !== undefined) pos = new Point(ee.clientX, ee.clientY);
let handled = false;
if (((e.target as HTMLElement).parentNode as HTMLElement).id === Eterna.PIXI_CONTAINER_ID) {
if (this._contextMenuDialogRef.isLive) {
Expand All @@ -347,7 +344,7 @@ export default abstract class GameMode extends AppMode {
const menu = this.createContextMenu();
if (menu != null) {
this._contextMenuDialogRef = this.addObject(
new ContextMenuDialog(menu, pos/* Flashbang.globalMouse */),
new ContextMenuDialog(menu, Flashbang.globalMouse),
this.contextMenuLayer
);
handled = true;
Expand Down Expand Up @@ -498,11 +495,6 @@ export default abstract class GameMode extends AppMode {
}
}

public getSequence(): [string, (number|null) [] | undefined] {
const sequenceString: string = this._poses[0].sequence.sequenceString();
return [sequenceString, this._poses[0].customNumbering];
}

protected showCopySequenceDialog(): void {
Assert.assertIsDefined(this.modeStack);
let sequenceString = this._poses[0].sequence.sequenceString();
Expand Down Expand Up @@ -580,10 +572,10 @@ export default abstract class GameMode extends AppMode {

protected _achievements: AchievementManager;

public _dialogRef: GameObjectRef = GameObjectRef.NULL;
protected _dialogRef: GameObjectRef = GameObjectRef.NULL;
protected _uiLockRef: GameObjectRef = GameObjectRef.NULL;
protected _notifRef: GameObjectRef = GameObjectRef.NULL;
public _contextMenuDialogRef: GameObjectRef = GameObjectRef.NULL;
protected _contextMenuDialogRef: GameObjectRef = GameObjectRef.NULL;

private _modeScriptInterface: ExternalInterfaceCtx;

Expand Down Expand Up @@ -612,30 +604,3 @@ export default abstract class GameMode extends AppMode {

protected _targetConditions: (TargetConditions | undefined)[] = [];
}

export class ContextMenuDialog extends Dialog<void> {
constructor(menu: ContextMenu, menuLoc: Point) {
super();
this._menu = menu;
this._menuLoc = menuLoc;
}

protected added(): void {
super.added();
this.addObject(this._menu, this.container);

this._menu.display.position.copyFrom(this._menuLoc);
this._menu.menuItemSelected.connect(() => this.close());
}

protected onBGClicked(): void {
this.close();
}

protected get bgAlpha(): number {
return 0;
}

private readonly _menu: ContextMenu;
private readonly _menuLoc: Point;
}
1 change: 0 additions & 1 deletion src/eterna/mode/PoseEdit/PoseEditMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as log from 'loglevel';
import {
Container, DisplayObject, Point, Sprite, Text, Rectangle, InteractionEvent
} from 'pixi.js';

import EPars, {RNABase, RNAPaint} from 'eterna/EPars';
import Eterna from 'eterna/Eterna';
import {PuzzleID} from 'eterna/EternaApp';
Expand Down
34 changes: 14 additions & 20 deletions src/eterna/pose2D/PaintCursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@ export default class PaintCursor extends GameObject implements Updatable {
this._color = col;
}

public getColor(): number {
return this._color;
}

public getOutColor(): number {
return this._outColor;
}

public setShape(shape: number): void {
public setShape(shape: number, whiteOutside: boolean = false): void {
switch (shape) {
case RNABase.ADENINE:
this._color = PaintCursor.YELLOW;
Expand Down Expand Up @@ -75,6 +67,8 @@ export default class PaintCursor extends GameObject implements Updatable {
this._color = PaintCursor.WHITE;
this._outColor = PaintCursor.NULL;
}

if (whiteOutside) this._outColor = PaintCursor.WHITE;
}

/* override */
Expand Down Expand Up @@ -110,15 +104,15 @@ export default class PaintCursor extends GameObject implements Updatable {
}

private readonly _graphics: Graphics;
public _color: number;
public _outColor: number;

public static readonly YELLOW = 0xFFFF00;
public static readonly BLUE = 0x0000FF;
public static readonly RED = 0xFF0000;
public static readonly GREEN = 0x00FF00;
public static readonly WHITE = 0xFFFFFF;
public static readonly CYAN = 0x7EFFFF;
public static readonly GREY = 0xC0C0C0;
public static readonly NULL = 0x0;
private _color: number;
private _outColor: number;

private static readonly YELLOW = 0xFFFF00;
private static readonly BLUE = 0x0000FF;
private static readonly RED = 0xFF0000;
private static readonly GREEN = 0x00FF00;
private static readonly WHITE = 0xFFFFFF;
private static readonly CYAN = 0x7EFFFF;
private static readonly GREY = 0xC0C0C0;
private static readonly NULL = 0x0;
}
21 changes: 6 additions & 15 deletions src/eterna/pose2D/Pose2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,6 @@ export default class Pose2D extends ContainerObject implements Updatable {

public set currentColor(col: RNAPaint) {
this._currentColor = col;
// syncronize the color change by 2D with 3D
/*
if (GameMode.mol3DGate) {
GameMode.mol3DGate.viewerEx?.setBaseColor(
GameMode.mol3DGate.getBaseColor(col)
);
}
*/
}

public get currentColor(): RNAPaint {
Expand Down Expand Up @@ -591,7 +583,7 @@ export default class Pose2D extends ContainerObject implements Updatable {
}
}

public onPoseMouseDownPropagate(e: InteractionEvent|null, closestIndex: number): void {
public onPoseMouseDownPropagate(e: InteractionEvent, closestIndex: number): void {
const altDown: boolean = Flashbang.app.isAltKeyDown;
const ctrlDown: boolean = Flashbang.app.isControlKeyDown || Flashbang.app.isMetaKeyDown;
const ctrlDownOrBaseMarking = ctrlDown || this.currentColor === RNAPaint.BASE_MARK;
Expand Down Expand Up @@ -918,7 +910,7 @@ export default class Pose2D extends ContainerObject implements Updatable {
this._customLayoutChanged = true;
}

public onPoseMouseDown(e: InteractionEvent | null, closestIndex: number): void {
public onPoseMouseDown(e: InteractionEvent, closestIndex: number): void {
const altDown: boolean = Flashbang.app.isAltKeyDown;
const shiftDown: boolean = Flashbang.app.isShiftKeyDown;
const ctrlDown: boolean = Flashbang.app.isControlKeyDown || Flashbang.app.isMetaKeyDown;
Expand Down Expand Up @@ -969,7 +961,7 @@ export default class Pose2D extends ContainerObject implements Updatable {
if (reg) reg.close();
});
}
e?.stopPropagation();
e.stopPropagation();
return;
}
if (this._annotationManager.annotationModeActive.value) {
Expand Down Expand Up @@ -1045,7 +1037,7 @@ export default class Pose2D extends ContainerObject implements Updatable {
if (reg) reg.close();
});
}
e?.stopPropagation();
e.stopPropagation();
return;
}
this._lastShiftedCommand = -1;
Expand All @@ -1067,7 +1059,7 @@ export default class Pose2D extends ContainerObject implements Updatable {
this.callAddBaseCallback(cmd[0], cmd[1], closestIndex);
}

e?.stopPropagation();
e.stopPropagation();
} else if (shiftDown && !this._annotationManager.annotationModeActive.value) {
this._shiftStart = -1;
this._shiftEnd = -1;
Expand Down Expand Up @@ -1292,7 +1284,6 @@ export default class Pose2D extends ContainerObject implements Updatable {
if (!this._annotationManager.annotationModeActive.value) {
this._paintCursor.display.visible = true;
this._paintCursor.setShape(this._currentColor);
this._paintCursor._outColor = PaintCursor.WHITE;
}

const strandName: string | null = this.getStrandName(closestIndex);
Expand Down Expand Up @@ -4213,7 +4204,7 @@ export default class Pose2D extends ContainerObject implements Updatable {
}

private readonly _baseLayer: Container = new Container();
public readonly _poseField: PoseField;
private readonly _poseField: PoseField;

private _width: number = 0;
private _height: number = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/eterna/pose3D/Pose3DWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import GameButton from 'eterna/ui/GameButton';
import Fonts from 'eterna/util/Fonts';
import ContextMenu from 'eterna/ui/ContextMenu';
import TextBalloon from 'eterna/ui/TextBalloon';
import {ContextMenuDialog} from 'eterna/mode/GameMode';
import ContextMenuDialog from 'eterna/ui/ContextMenuDialog';
import WindowBounds from './WindowBounds';
import PointerEventPropagator from './PointerEventPropagator';

Expand Down
4 changes: 0 additions & 4 deletions src/eterna/rnatypes/Sequence.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import EPars, {RNABase} from 'eterna/EPars';
import SecStruct from './SecStruct';

export interface UpdateSequenceCallback {
(resno:number, oldColr:number, color:number): void;
}

export default class Sequence {
constructor(baseArray: RNABase[]) {
this._baseArray = baseArray;
Expand Down
2 changes: 1 addition & 1 deletion webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = {
}
},
{
test: /\.(png|jpg|gif|mp3|ttf|cif)$/,
test: /\.(png|jpg|gif|mp3|ttf)$/,
type: 'asset/resource',
},
{
Expand Down

0 comments on commit 7391922

Please sign in to comment.