Skip to content

Commit

Permalink
Merge pull request #2496 from cesardlinx/issue_2248
Browse files Browse the repository at this point in the history
feat: showcase branding in coordinate view [closes #2248]
  • Loading branch information
DreadKnight authored Oct 3, 2023
2 parents e1507c1 + be649d3 commit e67631a
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 7 deletions.
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

1 comment on commit e67631a

@vercel
Copy link

@vercel vercel bot commented on e67631a Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.