Skip to content
Open
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
24 changes: 24 additions & 0 deletions HSTracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
1CCB4AEB1E8A4930003FD1AD /* LogEventHandlers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CCB4AEA1E8A4930003FD1AD /* LogEventHandlers.swift */; };
1CF204F91E83B74300037A42 /* MirrorHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CF204F81E83B74300037A42 /* MirrorHelper.swift */; };
340AAC051D0544AD0015FE33 /* StringTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 340AAC041D0544AD0015FE33 /* StringTracker.swift */; };
3C44E25B2E0B3F0700BB7316 /* BattlegroundsStatsPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C44E25A2E0B3F0700BB7316 /* BattlegroundsStatsPicker.swift */; };
3C44E25D2E0B3F3D00BB7316 /* StatTier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C44E25C2E0B3F3D00BB7316 /* StatTier.swift */; };
3C44E25F2E0B437400BB7316 /* PickData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C44E25E2E0B437400BB7316 /* PickData.swift */; };
3C44E2612E0B457700BB7316 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3C44E2602E0B457700BB7316 /* Colors.xcassets */; };
43050C621E6B484D007600EA /* Hearthstone.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 43050C611E6B484D007600EA /* Hearthstone.xcassets */; };
4305CA471CF434E30048E7EC /* Cards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4305CA461CF434E30048E7EC /* Cards.swift */; };
4308EB7E1D76AFE6000897C8 /* ReleaseChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4308EB7D1D76AFE6000897C8 /* ReleaseChannel.swift */; };
Expand Down Expand Up @@ -1314,6 +1318,10 @@
1CF1B58B1E815810007DCBF2 /* LogReaderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogReaderTests.swift; sourceTree = "<group>"; };
1CF204F81E83B74300037A42 /* MirrorHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MirrorHelper.swift; sourceTree = "<group>"; };
340AAC041D0544AD0015FE33 /* StringTracker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringTracker.swift; sourceTree = "<group>"; };
3C44E25A2E0B3F0700BB7316 /* BattlegroundsStatsPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BattlegroundsStatsPicker.swift; sourceTree = "<group>"; };
3C44E25C2E0B3F3D00BB7316 /* StatTier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatTier.swift; sourceTree = "<group>"; };
3C44E25E2E0B437400BB7316 /* PickData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickData.swift; sourceTree = "<group>"; };
3C44E2602E0B457700BB7316 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = "<group>"; };
43050C601E6B2C0E007600EA /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/TrackersPreferences.strings; sourceTree = "<group>"; };
43050C611E6B484D007600EA /* Hearthstone.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Hearthstone.xcassets; sourceTree = "<group>"; };
4305CA461CF434E30048E7EC /* Cards.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cards.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2548,6 +2556,16 @@
path = Parsers;
sourceTree = "<group>";
};
3C44E2592E0B3ED700BB7316 /* PickInfo */ = {
isa = PBXGroup;
children = (
3C44E25A2E0B3F0700BB7316 /* BattlegroundsStatsPicker.swift */,
3C44E25C2E0B3F3D00BB7316 /* StatTier.swift */,
3C44E25E2E0B437400BB7316 /* PickData.swift */,
);
path = PickInfo;
sourceTree = "<group>";
};
4323C5E31E1695DD00C97896 /* HearthMirror */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2607,6 +2625,7 @@
434106A11C9868620045655A /* Assets.xcassets */,
434106A21C9868620045655A /* Classes.xcassets */,
43050C611E6B484D007600EA /* Hearthstone.xcassets */,
3C44E2602E0B457700BB7316 /* Colors.xcassets */,
);
path = Assets;
sourceTree = "<group>";
Expand Down Expand Up @@ -3115,6 +3134,7 @@
4C1923972392E174007EBB0F /* Battlegrounds */ = {
isa = PBXGroup;
children = (
3C44E2592E0B3ED700BB7316 /* PickInfo */,
4C19239C2392FA7E007EBB0F /* BattlegroundsDetailsWindow.swift */,
4C1923A02392FB3F007EBB0F /* BattlegroundsDetailsWindow.xib */,
B8BB7ABB28369C9F008239CA /* BattlegroundsFinalBoard.swift */,
Expand Down Expand Up @@ -4406,6 +4426,7 @@
439C7EE41C777FA900D29859 /* Tracker.xib in Resources */,
43873CC11CA6E6C200F01CB4 /* WindowMove.xib in Resources */,
43B695651C920BD500F4D0AC /* CardList.xib in Resources */,
3C44E2612E0B457700BB7316 /* Colors.xcassets in Resources */,
C9BDB3C81D20BC4C00886A11 /* StatsTab.xib in Resources */,
434106A41C9868620045655A /* Assets.xcassets in Resources */,
B8BD3BAA2C41C50F001E85B7 /* BattlegroundsCompositionStatsBar.xib in Resources */,
Expand Down Expand Up @@ -4736,6 +4757,7 @@
43EBA3A31D1299AC0093B1C2 /* CardHudContainer.swift in Sources */,
B8B790322C975B0200DD33EC /* LoveEverlastingEnchantment.swift in Sources */,
B81B3D8D2D4099B000DC9EB0 /* TramHeist.swift in Sources */,
3C44E25B2E0B3F0700BB7316 /* BattlegroundsStatsPicker.swift in Sources */,
4361D8341DC8A21800D831CF /* BnetGameType.swift in Sources */,
B8E1E5FE2D0CA1CD00383975 /* HabeasCorpses.swift in Sources */,
B8AF0C6B2B83A7AD00B65F63 /* MulliganGuideParams.swift in Sources */,
Expand Down Expand Up @@ -4826,6 +4848,7 @@
B8B78FE52C9676B500DD33EC /* AquaArchivistEnchantment.swift in Sources */,
B8B78FBC2C952A4C00DD33EC /* MagicalDollhouseEnchantment.swift in Sources */,
B81B3D9D2D4129F000DC9EB0 /* LiftOff.swift in Sources */,
3C44E25D2E0B3F3D00BB7316 /* StatTier.swift in Sources */,
B804FC392944B1DA00F74CD9 /* ViewModel.swift in Sources */,
B8B78FC42C952C5600DD33EC /* TrailMixEnchantment.swift in Sources */,
B8B790592C97841400DD33EC /* CommanderUlthokEnchantment.swift in Sources */,
Expand Down Expand Up @@ -4980,6 +5003,7 @@
439212151DEF5A5E0017AAE5 /* MultiClassGroup.swift in Sources */,
434EAC961DBCD3E8009C7636 /* NSAlert.swift in Sources */,
B8B78FFC2C970B7500DD33EC /* CoilfangConstrictorEnchantment.swift in Sources */,
3C44E25F2E0B437400BB7316 /* PickData.swift in Sources */,
434910501D09770000B22DB2 /* PlayerBoard.swift in Sources */,
B89865642D8E157600BA5649 /* PendantOfEarth.swift in Sources */,
B898994D2CA450720011B184 /* BattlegroundsTrinketPickState.swift in Sources */,
Expand Down
38 changes: 38 additions & 0 deletions HSTracker/Assets/Colors.xcassets/PickHeader.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.216",
"green" : "0.094",
"red" : "0.200"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.216",
"green" : "0.094",
"red" : "0.200"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.086",
"green" : "0.082",
"red" : "0.078"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.086",
"green" : "0.082",
"red" : "0.078"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
45 changes: 30 additions & 15 deletions HSTracker/Core/Extensions/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import AppKit
import SwiftUICore

extension NSColor {
func darken(amount: CGFloat = 0.5) -> NSColor {
Expand All @@ -24,24 +25,38 @@ extension NSColor {
}

class func fromHexString(hex: String, alpha: CGFloat = 1.0) -> NSColor? {
// Handle two types of literals: 0x and # prefixed
var cleanedString = ""
if hex.hasPrefix("0x") {
cleanedString = hex.substring(from: 2)
} else if hex.hasPrefix("#") {
cleanedString = hex.substring(from: 1)
}
var theInt: UInt64 = 0
let scanner = Scanner(string: cleanedString)
scanner.scanHexInt64(&theInt)
let myAlpha = cleanedString.count == 8 ? CGFloat((theInt & 0xFF000000) >> 24) / 255.0 : alpha
let red = CGFloat((theInt & 0xFF0000) >> 16) / 255.0
let green = CGFloat((theInt & 0xFF00) >> 8) / 255.0
let blue = CGFloat((theInt & 0xFF)) / 255.0
return NSColor(colorSpace: .deviceRGB, components: [red, green, blue, myAlpha], count: 4)
let (red, green, blue, hexAlpha) = componentsFromHex(hex: hex)
return NSColor(colorSpace: .deviceRGB, components: [red, green, blue, hexAlpha ?? alpha], count: 4)
}

class func fromRgb(_ r: Int, _ g: Int, _ b: Int) -> NSColor {
return NSColor(colorSpace: .deviceRGB, components: [ CGFloat(r) / 255.0, CGFloat(g) / 255.0, CGFloat(b) / 255.0, 1.0 ], count: 4)
}
}

@available(macOS 10.15, *)
extension Color {
init?(hex: String) {
let (red, green, blue, alpha) = componentsFromHex(hex: hex)

self.init(red: red, green: green, blue: blue, opacity: alpha ?? 1.0)
}
}

func componentsFromHex(hex: String) -> (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat?) {
// Handle two types of literals: 0x and # prefixed
var cleanedString = ""
if hex.hasPrefix("0x") {
cleanedString = hex.substring(from: 2)
} else if hex.hasPrefix("#") {
cleanedString = hex.substring(from: 1)
}
var theInt: UInt64 = 0
let scanner = Scanner(string: cleanedString)
scanner.scanHexInt64(&theInt)
let alpha = cleanedString.count == 8 ? CGFloat((theInt & 0xFF000000) >> 24) / 255.0 : nil
let red = CGFloat((theInt & 0xFF0000) >> 16) / 255.0
let green = CGFloat((theInt & 0xFF00) >> 8) / 255.0
let blue = CGFloat((theInt & 0xFF)) / 255.0
return (red, green, blue, alpha)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
//

import Foundation
import SwiftUI

class BattlegroundsSingleHeroStats: NSView {
@IBOutlet var contentView: NSView!

@IBOutlet var battlegroundsHeroHeader: BattlegroundsHeroHeader!
@IBOutlet var battlegroundsHeroHeader: NSView!
@IBOutlet var heroPortraitContainer: NSView!
@IBOutlet var compositions: BattlegroundsCompositionPopularity!

Expand Down Expand Up @@ -62,7 +63,17 @@ class BattlegroundsSingleHeroStats: NSView {
heroPortraitContainer.addTrackingArea(trackingArea)

compositions.viewModel = viewModel.bgsCompsPopularityVM
battlegroundsHeroHeader.viewModel = viewModel.bgsHeroHeaderVM

let heroStatFrame = NSRect(x: 28, y: 470, width: 236, height: 72);
if #available(macOS 10.15, *) {
battlegroundsHeroHeader = NSHostingView(rootView: BattlegroundsStatsPicker(viewModel: viewModel.bgsHeroHeaderVM))
battlegroundsHeroHeader.frame = heroStatFrame
} else {
let view = BattlegroundsHeroHeader(frame: heroStatFrame)
view.viewModel = viewModel.bgsHeroHeaderVM
battlegroundsHeroHeader = view
}
addSubview(battlegroundsHeroHeader)

update()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22689"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="BattlegroundsSingleHeroStats" customModule="HSTracker" customModuleProvider="target">
<connections>
<outlet property="armorTierTooltipRange" destination="ltz-0w-Isv" id="ZCa-Br-y9q"/>
<outlet property="battlegroundsHeroHeader" destination="dJn-dd-3p5" id="2M5-ai-Xdl"/>
<outlet property="compositions" destination="5q0-Cd-eRk" id="wMX-p5-ikQ"/>
<outlet property="contentView" destination="c22-O7-iKe" id="NUa-12-oO3"/>
<outlet property="heroPortraitContainer" destination="u1e-O1-gPf" id="uAr-60-nrV"/>
Expand All @@ -18,24 +17,24 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe" userLabel="BattlegroundsSingleHero">
<rect key="frame" x="0.0" y="0.0" width="266" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="260" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="dJn-dd-3p5" customClass="BattlegroundsHeroHeader" customModule="HSTracker" customModuleProvider="target">
<rect key="frame" x="15" y="496" width="236" height="72"/>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="dJn-dd-3p5">
<rect key="frame" x="12" y="496" width="236" height="72"/>
<constraints>
<constraint firstAttribute="width" constant="236" id="6EJ-DD-qF4"/>
<constraint firstAttribute="height" constant="72" id="V4j-aR-g3F"/>
</constraints>
</customView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="u1e-O1-gPf" userLabel="HeroPortraitContainer">
<rect key="frame" x="15" y="132" width="236" height="364"/>
<customView misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="u1e-O1-gPf" userLabel="HeroPortraitContainer">
<rect key="frame" x="12" y="132" width="230" height="364"/>
<constraints>
<constraint firstAttribute="width" constant="236" id="Evg-vn-ueL"/>
</constraints>
</customView>
<customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5q0-Cd-eRk" userLabel="Compositions" customClass="BattlegroundsCompositionPopularity" customModule="HSTracker" customModuleProvider="target">
<rect key="frame" x="15" y="0.0" width="236" height="72"/>
<rect key="frame" x="12" y="0.0" width="236" height="72"/>
<constraints>
<constraint firstAttribute="width" constant="236" id="3TF-VP-H0t"/>
<constraint firstAttribute="height" constant="72" id="Aqz-dS-TZg"/>
Expand Down Expand Up @@ -70,7 +69,7 @@
<customView translatesAutoresizingMaskIntoConstraints="NO" id="5OH-eu-5bq">
<rect key="frame" x="0.0" y="-2" width="169" height="88"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Z61-9S-dVs">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Z61-9S-dVs">
<rect key="frame" x="6" y="62" width="157" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="Il1-tv-yoM"/>
Expand All @@ -81,7 +80,7 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="0kR-WP-yxU">
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="0kR-WP-yxU">
<rect key="frame" x="6" y="20" width="157" height="42"/>
<constraints>
<constraint firstAttribute="height" constant="42" id="Dfo-yv-4Xz"/>
Expand All @@ -92,7 +91,7 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5hA-bl-Zuo" userLabel="ArmorTooltipRange">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5hA-bl-Zuo" userLabel="ArmorTooltipRange">
<rect key="frame" x="6" y="7" width="157" height="13"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="ArmorTooltipRange" id="yQO-8l-IQq">
<font key="font" metaFont="system" size="10"/>
Expand Down
Loading