Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: showcase branding in coordinate view [#2248] #2496

Merged
merged 4 commits into from
Oct 3, 2023
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
4 changes: 3 additions & 1 deletion src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Point, configure as configurePointFacade } from './utility/pointfacade'
import { pretty as version } from './utility/version';
import { Ability } from './ability';
import { Effect } from './effect';
import { GameConfig } from './script';
import { GameConfig, adjustBrand } from './script';
import { Trap } from './utility/trap';
import { Drop } from './drop';
import { CreatureType, Realm, UnitData } from './data/types';
Expand Down Expand Up @@ -1304,6 +1304,8 @@ export default class Game {

// Removed individual args from definition because we are using the arguments variable.
onStartOfRound(/* creature, callback */) {
// position brand when round starts
adjustBrand();
this.triggerDeleteEffect('onStartOfRound', 'all');
}

Expand Down
4 changes: 4 additions & 0 deletions src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,10 @@
<div id="queuewrapper"></div>
</div>

<div id="brandlogo" class="hide">
<div></div>
</div>

<div id="rightpanel">
<div style="position:relative">
<div id="playerbutton" class="quickinfowrapper togglescore vignette active frame button">
Expand Down
19 changes: 19 additions & 0 deletions src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,22 @@ export function isEmpty(obj) {

return true;
}

/**
* Method that resizes and positions brand logo
* based on the arena
*/
export function adjustBrand() {
// fix size
const arenaWidth = $j('#combatwrapper').innerWidth();
let scaledSize = (arenaWidth * 555) / 1070;
scaledSize = scaledSize > 555 ? 555 : scaledSize;
$j('#brandlogo div').css('background-size', scaledSize);
$j('#brandlogo div').css('width', scaledSize);

// fix position
const arenaMarginTopPx = $j('#combatwrapper canvas').css('margin-top');
const arenaMarginTop = Number(arenaMarginTopPx.slice(0, -2));
const offset = 125 - (19 * arenaMarginTop) / 65;
$j('#brandlogo').css('top', arenaMarginTop + offset);
}
31 changes: 31 additions & 0 deletions src/style/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -2044,3 +2044,34 @@ input {
color: #fff;
top: 20%;
}

#brandlogo {
display: block;
margin: auto;
width: 100%;
opacity: 1;
z-index: 1;
position: absolute;
top: 105px;
transition: opacity 300ms cubic-bezier(.39,.58,.57,1);;

div {
height: 125px;
background-image: url('~assets/interface/AncientBeast.png');
background-repeat: no-repeat;
display: block;
width: 555px;
max-width: 555px;
margin: 0 auto;
}

&.hide {
opacity: 0;
}
}

@media only screen and (max-width: 410px) {
#brandlogo {
display: none;
}
}
25 changes: 25 additions & 0 deletions src/ui/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,24 @@ export class Hotkeys {
}

pressShiftKeyDown() {
this.ui.$brandlogo.removeClass('hide');
this.ui.game.grid.showGrid(true);
this.ui.game.grid.showCurrentCreatureMovementInOverlay(this.ui.game.activeCreature);
}

pressShiftKeyUp() {
this.ui.$brandlogo.addClass('hide');
this.ui.game.grid.showGrid(false);
this.ui.game.grid.cleanOverlay();
this.ui.game.grid.redoLastQuery();
}
pressControlKeyDown() {
this.ui.$brandlogo.addClass('hide');
}

pressControlKeyUp() {
this.ui.$brandlogo.addClass('hide');
}

pressSpace() {
!this.ui.dashopen && this.ui.game.grid.confirmHex();
Expand Down Expand Up @@ -224,6 +233,22 @@ export function getHotKeys(hk) {
hk.pressShiftKeyUp();
},
},
ControlLeft: {
onkeydown() {
hk.pressControlKeyDown();
},
onkeyup() {
hk.pressControlKeyUp();
},
},
ControlRight: {
onkeydown() {
hk.pressControlKeyDown();
},
onkeyup() {
hk.pressControlKeyUp();
},
},
Space: {
onkeydown() {
hk.pressSpace();
Expand Down
12 changes: 10 additions & 2 deletions src/ui/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as $j from 'jquery';
import * as time from '../utility/time';
import * as emoji from 'node-emoji';
import { Hotkeys, getHotKeys } from './hotkeys';
import { adjustBrand } from '../script';

import { Button, ButtonStateEnum } from './button';
import { Chat } from './chat';
Expand Down Expand Up @@ -29,12 +30,13 @@ export class UI {
* NOTE : attributes and variables starting with $ are jquery element
* and jquery function can be called directly from them.
*
* $display : UI container
* $queue : Queue container
* $display : UI container
* $queue : Queue container
* $textbox : Chat and log container
* $activebox : Current active creature panel (left panel) container
* $dash : Overview container
* $grid : Creature grid container
* $brandlogo: Brand logo container
*
* selectedCreature : String : ID of the visible creature card
* selectedPlayer : Integer : ID of the selected player in the dash
Expand All @@ -57,6 +59,7 @@ export class UI {
this.$grid = $j(this.#makeCreatureGrid(document.getElementById('creaturerasterwrapper')));
this.$activebox = $j('#activebox');
this.$scoreboard = $j('#scoreboard');
this.$brandlogo = $j('#brandlogo');
this.active = false;

this.queue = UI.#getQueue(this, document.getElementById('queuewrapper'));
Expand Down Expand Up @@ -522,6 +525,9 @@ export class UI {
e.preventDefault();
});

// adjust brand logo on window resize
$j(window).on('resize', (ev) => adjustBrand());

this.$dash.find('.section.numbers .stat').on('mouseover', (event) => {
const $section = $j(event.target).closest('.section');
const which = $section.hasClass('stats') ? '.stats_desc' : '.masteries_desc';
Expand Down Expand Up @@ -2302,11 +2308,13 @@ export class UI {
}, 2000);

const onTurnEndMouseEnter = ifGameNotFrozen(() => {
ui.$brandlogo.removeClass('hide');
ui.game.grid.showGrid(true);
ui.game.grid.showCurrentCreatureMovementInOverlay(ui.game.activeCreature);
});

const onTurnEndMouseLeave = () => {
ui.$brandlogo.addClass('hide');
ui.game.grid.showGrid(false);
ui.game.grid.cleanOverlay();
ui.game.grid.redoLastQuery();
Expand Down
10 changes: 6 additions & 4 deletions src/utility/hex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,15 @@ export class Hex {
if (this.overlayClasses.match(/reachable/)) {
targetAlpha = true;
this.overlay.loadTexture('hex_path');
// hover when creature is inactive
} else if (this.overlayClasses.match(/hover/)
&& this.displayClasses.indexOf(`creature player${player}`) === -1) {
// hover when creature is inactive
} else if (
this.overlayClasses.match(/hover/) &&
this.displayClasses.indexOf(`creature player${player}`) === -1
) {
this.display.loadTexture('hex_path');
this.display.alpha = 1;
this.overlay.loadTexture(`hex_hover_p${player}`);
// hover over active player
// hover over active player
} else if (this.overlayClasses.match(/hover/)) {
this.display.loadTexture('hex_path');
} else {
Expand Down
Loading