feat(Database) Updating database to latest patch. Updating Calc hotkey UI to match
This commit is contained in:
@@ -13,33 +13,60 @@
|
||||
|
||||
<InputPanelComponent>
|
||||
<div class="keyContainer">
|
||||
@foreach (var hotkey in hotkeys)
|
||||
{
|
||||
if (hotkey.IsHidden)
|
||||
{
|
||||
@foreach (var hotkey in hotkeys) {
|
||||
if (hotkey.IsHidden) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var color = hotkey.KeyText.Equals("SPACE") && KeyService.IsHoldingSpace() || KeyService.GetAllPressedKeys().Contains(hotkey.KeyText)
|
||||
|
||||
var color = (hotkey.KeyText.Equals("SPACE") && KeyService.IsHoldingSpace()) || KeyService.GetAllPressedKeys().Contains(hotkey.KeyText)
|
||||
? "#0a0f12" : hotkey.GetColor();
|
||||
|
||||
var x = hotkey.PositionX * Size;
|
||||
var y = hotkey.PositionY * Size;
|
||||
var y = hotkey.PositionY * Size + (hotkey.PositionY == 0 ? 5 : -50);
|
||||
|
||||
var width = Size;
|
||||
var height = hotkey.PositionY == 0 ? 50 : Size;
|
||||
|
||||
var borderRadius = hotkey.PositionY == 0 ? 12 : 0;
|
||||
|
||||
var border = "1px solid black";
|
||||
if (hotkey.KeyText.Equals(key))
|
||||
{
|
||||
if (hotkey.KeyText.Equals(key)) {
|
||||
border = "5px solid black";
|
||||
}
|
||||
if (hotkey.KeyText.Equals(controlGroup))
|
||||
{
|
||||
if (hotkey.KeyText.Equals(controlGroup)) {
|
||||
color = "#257525";
|
||||
}
|
||||
|
||||
if (hotkey.KeyText.Equals("SPACE") && KeyService.IsHoldingSpace()) {
|
||||
border = "5px solid green";
|
||||
}
|
||||
|
||||
if (hotkey.KeyText.Equals("SPACE") && KeyService.IsHoldingSpace())
|
||||
{
|
||||
border = "5px solid green";
|
||||
}
|
||||
var keyText = hotkey.KeyText.Equals("CAPSLOCK") ? "Caps"
|
||||
: hotkey.KeyText.Equals("CONTROL") ? "Ctrl"
|
||||
: hotkey.KeyText.Equals("SHIFT") ? "Shift"
|
||||
: hotkey.KeyText.Equals("TAB") ? "Tab"
|
||||
: hotkey.KeyText.Equals("SPACE") ? "Space" : hotkey.KeyText;
|
||||
|
||||
|
||||
var controlStyle = $"background-color:{color}; " +
|
||||
$"width: {width}px; " +
|
||||
"border-top: 1px solid black; " +
|
||||
"border-left: 1px solid black; " +
|
||||
"border-right: 1px solid black; " +
|
||||
$"border-top-left-radius: {borderRadius}px; " +
|
||||
$"border-top-right-radius: {borderRadius}px; " +
|
||||
"overflow: hidden; " +
|
||||
"text-align: center;";
|
||||
|
||||
var keyStyle = $"background-color:{color}; " +
|
||||
$"border: {border}; " +
|
||||
$"width: {width}px; " +
|
||||
$"height: {height}px; " +
|
||||
"overflow: hidden; " +
|
||||
"padding: 4px;";
|
||||
|
||||
var usedStyle = hotkey.PositionY == 0 ? controlStyle : keyStyle;
|
||||
|
||||
<div style="position:relative;
|
||||
cursor:pointer;
|
||||
@@ -48,35 +75,25 @@
|
||||
width: 0px;
|
||||
height: 0px;">
|
||||
|
||||
<div @onclick="((e)=> ButtonClicked(e, hotkey))" style="background-color:@color;
|
||||
border: @border;
|
||||
width: @Size.ToString()px;
|
||||
height: @Size.ToString()px;
|
||||
overflow: hidden;
|
||||
padding: 4px;">
|
||||
@hotkey.KeyText
|
||||
@foreach (var entity in data.Values)
|
||||
{
|
||||
if (InvalidKey(entity, hotkey) || InvalidKeyGroup(entity, hotkey) || InvalidHoldSpace(entity))
|
||||
{
|
||||
<div @onclick="e => ButtonClicked(e, hotkey)" style="@usedStyle">
|
||||
@keyText
|
||||
@foreach (var entity in data.Values) {
|
||||
if (InvalidKey(entity, hotkey) || InvalidKeyGroup(entity, hotkey) || InvalidHoldSpace(entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (InvalidFaction(entity))
|
||||
{
|
||||
if (InvalidFaction(entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (InvalidVanguard(entity) || InvalidNonVanguard(entity))
|
||||
{
|
||||
if (InvalidVanguard(entity) || InvalidNonVanguard(entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var isVanguard = entity.VanguardAdded() != null;
|
||||
var style = isVanguard ? "font-weight: bold;" : "";
|
||||
|
||||
if (BuildOrderService.WillMeetRequirements(entity) == null)
|
||||
{
|
||||
if (BuildOrderService.WillMeetRequirements(entity) == null) {
|
||||
style += "color:gray; font-style: italic;";
|
||||
}
|
||||
|
||||
@@ -93,7 +110,7 @@
|
||||
.keyContainer {
|
||||
width: 400px;
|
||||
max-width: 95vw;
|
||||
height: 400px;
|
||||
height: 350px;
|
||||
outline: 3px solid black;
|
||||
border-radius: 8px;
|
||||
background-color: #282A30;
|
||||
@@ -120,8 +137,7 @@
|
||||
private string controlGroup = "C";
|
||||
private string key = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
protected override void OnInitialized() {
|
||||
base.OnInitialized();
|
||||
|
||||
KeyService.Subscribe(OnKeyPressed);
|
||||
@@ -129,8 +145,7 @@
|
||||
BuildOrderService.Subscribe(OnBuilderOrderChanged);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
void IDisposable.Dispose() {
|
||||
KeyService.Unsubscribe(OnKeyPressed);
|
||||
FilterService.Unsubscribe(StateHasChanged);
|
||||
BuildOrderService.Unsubscribe(OnBuilderOrderChanged);
|
||||
@@ -138,17 +153,14 @@
|
||||
|
||||
int completedTimeCount = 0;
|
||||
|
||||
void OnBuilderOrderChanged()
|
||||
{
|
||||
if (BuildOrderService.UniqueCompletedTimes.Count != completedTimeCount)
|
||||
{
|
||||
void OnBuilderOrderChanged() {
|
||||
if (BuildOrderService.UniqueCompletedTimes.Count != completedTimeCount) {
|
||||
completedTimeCount = BuildOrderService.UniqueCompletedTimes.Count;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ShouldRender()
|
||||
{
|
||||
protected override bool ShouldRender() {
|
||||
#if DEBUG
|
||||
JsRuntime.InvokeVoidAsync("console.time", "HotKeyViewerComponent");
|
||||
#endif
|
||||
@@ -156,18 +168,15 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
protected override void OnAfterRender(bool firstRender) {
|
||||
#if DEBUG
|
||||
JsRuntime.InvokeVoidAsync("console.timeEnd", "HotKeyViewerComponent");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Move to Filter Service
|
||||
bool InvalidFaction(EntityModel entity)
|
||||
{
|
||||
if (entity.Faction() != null && entity.Faction()?.Faction != FilterService.GetFaction() && FilterService.GetFaction() != DataType.Any)
|
||||
{
|
||||
bool InvalidFaction(EntityModel entity) {
|
||||
if (entity.Faction() != null && entity.Faction()?.Faction != FilterService.GetFaction() && FilterService.GetFaction() != DataType.Any) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -175,12 +184,10 @@
|
||||
}
|
||||
|
||||
// Move to Filter Service
|
||||
bool InvalidVanguard(EntityModel entity)
|
||||
{
|
||||
bool InvalidVanguard(EntityModel entity) {
|
||||
if (entity.VanguardAdded() != null
|
||||
&& entity.VanguardAdded()?.ImmortalId != FilterService.GetImmortal()
|
||||
&& FilterService.GetImmortal() != DataType.Any)
|
||||
{
|
||||
&& FilterService.GetImmortal() != DataType.Any) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -188,14 +195,10 @@
|
||||
}
|
||||
|
||||
// Move to Filter Service
|
||||
bool InvalidNonVanguard(EntityModel entity)
|
||||
{
|
||||
if (entity.Replaceds().Count > 0)
|
||||
{
|
||||
foreach (var replaced in entity.Replaceds())
|
||||
{
|
||||
if (FilterService.GetImmortal() == replaced.ImmortalId)
|
||||
{
|
||||
bool InvalidNonVanguard(EntityModel entity) {
|
||||
if (entity.Replaceds().Count > 0) {
|
||||
foreach (var replaced in entity.Replaceds()) {
|
||||
if (FilterService.GetImmortal() == replaced.ImmortalId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -204,116 +207,90 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InvalidKey(EntityModel entity, HotkeyModel key)
|
||||
{
|
||||
if (entity.Hotkey()?.Hotkey == key.KeyText)
|
||||
{
|
||||
bool InvalidKey(EntityModel entity, HotkeyModel key) {
|
||||
if (entity.Hotkey()?.Hotkey == key.KeyText) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidKeyGroup(EntityModel entity, HotkeyModel key)
|
||||
{
|
||||
if (entity.Hotkey()?.HotkeyGroup == controlGroup)
|
||||
{
|
||||
bool InvalidKeyGroup(EntityModel entity, HotkeyModel key) {
|
||||
if (entity.Hotkey()?.HotkeyGroup == controlGroup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidKey(EntityModel entity)
|
||||
{
|
||||
if (entity.Hotkey()?.Hotkey == key)
|
||||
{
|
||||
bool InvalidKey(EntityModel entity) {
|
||||
if (entity.Hotkey()?.Hotkey == key) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidKeyGroup(EntityModel entity)
|
||||
{
|
||||
if (entity.Hotkey()?.HotkeyGroup == controlGroup)
|
||||
{
|
||||
bool InvalidKeyGroup(EntityModel entity) {
|
||||
if (entity.Hotkey()?.HotkeyGroup == controlGroup) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidHoldSpace(EntityModel entity)
|
||||
{
|
||||
if (entity.Hotkey()?.HoldSpace == KeyService.IsHoldingSpace())
|
||||
{
|
||||
bool InvalidHoldSpace(EntityModel entity) {
|
||||
if (entity.Hotkey()?.HoldSpace == KeyService.IsHoldingSpace()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnKeyPressed()
|
||||
{
|
||||
void OnKeyPressed() {
|
||||
var controlGroupWas = controlGroup;
|
||||
var keyWas = key;
|
||||
|
||||
|
||||
if (KeyService.GetAllPressedKeys().Contains("Z"))
|
||||
{
|
||||
if (KeyService.GetAllPressedKeys().Contains("Z")) {
|
||||
controlGroup = "Z";
|
||||
}
|
||||
if (KeyService.GetAllPressedKeys().Contains("TAB"))
|
||||
{
|
||||
if (KeyService.GetAllPressedKeys().Contains("TAB")) {
|
||||
controlGroup = "TAB";
|
||||
}
|
||||
if (KeyService.GetAllPressedKeys().Contains("C"))
|
||||
{
|
||||
if (KeyService.GetAllPressedKeys().Contains("C")) {
|
||||
controlGroup = "C";
|
||||
}
|
||||
if (KeyService.GetAllPressedKeys().Contains("D"))
|
||||
{
|
||||
if (KeyService.GetAllPressedKeys().Contains("D")) {
|
||||
controlGroup = "D";
|
||||
}
|
||||
if (KeyService.GetAllPressedKeys().Contains("1"))
|
||||
{
|
||||
controlGroup = "1";
|
||||
if (KeyService.GetAllPressedKeys().Contains("V")) {
|
||||
controlGroup = "V";
|
||||
}
|
||||
//TODO This could be better. Duplicated code
|
||||
if (KeyService.GetAllPressedKeys().Contains("2"))
|
||||
{
|
||||
controlGroup = "2";
|
||||
if (KeyService.GetAllPressedKeys().Contains("ALT")) {
|
||||
controlGroup = "ALT";
|
||||
}
|
||||
if (KeyService.GetAllPressedKeys().Contains("SHIFT"))
|
||||
{
|
||||
if (KeyService.GetAllPressedKeys().Contains("SHIFT")) {
|
||||
controlGroup = "SHIFT";
|
||||
}
|
||||
|
||||
if (KeyService.GetAllPressedKeys().Contains("CONTROL"))
|
||||
{
|
||||
if (KeyService.GetAllPressedKeys().Contains("CONTROL")) {
|
||||
controlGroup = "CONTROL";
|
||||
}
|
||||
|
||||
if (KeyService.GetAllPressedKeys().Count > 0)
|
||||
{
|
||||
if (KeyService.GetAllPressedKeys().Count > 0) {
|
||||
key = KeyService.GetAllPressedKeys().First();
|
||||
}
|
||||
|
||||
if (controlGroupWas != controlGroup || keyWas != key)
|
||||
{
|
||||
if (controlGroupWas != controlGroup || keyWas != key) {
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void HandleClick()
|
||||
{
|
||||
private void HandleClick() {
|
||||
var hotkey = KeyService.GetHotkey();
|
||||
|
||||
if (hotkey == "")
|
||||
{
|
||||
if (hotkey == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hotkey == "`")
|
||||
{
|
||||
if (hotkey == "`") {
|
||||
BuildOrderService.RemoveLast();
|
||||
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval());
|
||||
return;
|
||||
@@ -326,38 +303,31 @@
|
||||
|
||||
var entity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (BuildOrderService.Add(entity, EconomyService))
|
||||
{
|
||||
if (BuildOrderService.Add(entity, EconomyService)) {
|
||||
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval());
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonClicked(MouseEventArgs mouseEventArgs, HotkeyModel hotkey)
|
||||
{
|
||||
private void ButtonClicked(MouseEventArgs mouseEventArgs, HotkeyModel hotkey) {
|
||||
DataCollectionService.SendEvent(
|
||||
DataCollectionKeys.BuildCalcInput,
|
||||
new Dictionary<string, string> {{"key", hotkey.KeyText.ToLower()}, {"input-source", "mouse"}}
|
||||
DataCollectionKeys.BuildCalcInput,
|
||||
new Dictionary<string, string> { { "key", hotkey.KeyText.ToLower() }, { "input-source", "mouse" } }
|
||||
);
|
||||
|
||||
|
||||
if (hotkey.KeyText.Equals(HotKeyType.SPACE.ToString()))
|
||||
{
|
||||
if (KeyService.IsHoldingSpace())
|
||||
{
|
||||
|
||||
|
||||
if (hotkey.KeyText.Equals(HotKeyType.SPACE.ToString())) {
|
||||
if (KeyService.IsHoldingSpace()) {
|
||||
KeyService.RemovePressedKey(hotkey.KeyText);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
KeyService.AddPressedKey(hotkey.KeyText);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
KeyService.AddPressedKey(hotkey.KeyText);
|
||||
KeyService.RemovePressedKey(hotkey.KeyText);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user