Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Release 2.6.1 Update 2
Browse files Browse the repository at this point in the history
Attempt to implement a new way to show badlyDamageWarning (UNFINISHED).

This commit contains some unfinished code, if you want to compile this app by yourself, consider to clone the last commit.
  • Loading branch information
ming900518 committed Jan 6, 2021
1 parent 8025650 commit 5220b6f
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 40 deletions.
4 changes: 2 additions & 2 deletions KanColleCommand.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@
INFOPLIST_FILE = KanColleCommand/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = "1.0 (TW.CHT-R2.6.1Beta1)";
MARKETING_VERSION = "1.0 (TW.CHT-R2.6.1Beta2)";
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = tw.mingchang.ikancollecmd;
PRODUCT_NAME = iKanColleCmd;
Expand Down Expand Up @@ -1014,7 +1014,7 @@
INFOPLIST_FILE = KanColleCommand/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = "1.0 (TW.CHT-R2.6.1Beta1)";
MARKETING_VERSION = "1.0 (TW.CHT-R2.6.1Beta2)";
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = tw.mingchang.ikancollecmd;
PRODUCT_NAME = iKanColleCmd;
Expand Down
Binary file not shown.
4 changes: 4 additions & 0 deletions KanColleCommand/Page/AppearanceVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ extension AppearanceVC: UITableViewDelegate {
Setting.saveUseTheme(value: 1)
self.appearanceTable.reloadData()
})
// dialog.addAction(UIAlertAction(title: "自訂背景圖片", style: .default) { action in
// Setting.saveUseTheme(value: 2)
// self.appearanceTable.reloadData()
// })
self.present(dialog, animated: true)
}
} else if (indexPath.section == 2) {
Expand Down
3 changes: 3 additions & 0 deletions KanColleCommand/Page/BattleVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class BattleVC: UIViewController {
self.view.backgroundColor = ViewController.DEFAULT_BACKGROUND
} else {
self.view.backgroundColor = UIColor.black.withAlphaComponent(0.8)
if Setting.getUseTheme() == 2 {
// TODO
}
}
setupList()
setupInfoViews()
Expand Down
3 changes: 3 additions & 0 deletions KanColleCommand/Page/FleetVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class FleetVC: UIViewController {
self.view.backgroundColor = ViewController.DEFAULT_BACKGROUND
} else {
self.view.backgroundColor = UIColor.black.withAlphaComponent(0.8)
if Setting.getUseTheme() == 2 {
// TODO
}
}
setupList()
setupIndicator()
Expand Down
3 changes: 3 additions & 0 deletions KanColleCommand/Page/MissionVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class MissionVC: UIViewController {
self.view.backgroundColor = ViewController.DEFAULT_BACKGROUND
} else {
self.view.backgroundColor = UIColor.black.withAlphaComponent(0.8)
if Setting.getUseTheme() == 2 {
// TODO
}
}
setupList()
Oyodo.attention().watch(data: Mission.instance.questMap) { (event: Event<Dictionary<Int, Quest>>) in
Expand Down
10 changes: 10 additions & 0 deletions KanColleCommand/Util/Setting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,14 @@ class Setting {
static func saveCustomProxyPass(value: String) {
UserDefaults.standard.set(value, forKey: kCustomProxyPass)
}

private static let kBDPstatus = "BDPstatus"

static func getBDPstatus() -> Bool {
return UserDefaults.standard.bool(forKey: kBDPstatus)
}

static func saveBDPstatus(value: Bool) {
UserDefaults.standard.set(value, forKey: kBDPstatus)
}
}
146 changes: 111 additions & 35 deletions KanColleCommand/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,9 @@ class ViewController: UIViewController, UIScrollViewDelegate {
webView.scrollView.contentInsetAdjustmentBehavior = .always;
webView.scalesPageToFit = true;
}
Setting.saveBDPstatus(value: false)
NotificationCenter.default.addObserver(self, selector: #selector(reloadGame), name: Constants.RELOAD_GAME, object: nil)

let badlyDamageWarning = UIImageView(image: UIImage(named: "badly_damage_warning.png")?.resizableImage(
withCapInsets: UIEdgeInsets.init(top: 63, left: 63, bottom: 63, right: 63), resizingMode: .stretch))
badlyDamageWarning.isHidden = true
self.view.addSubview(badlyDamageWarning)
badlyDamageWarning.snp.makeConstraints { maker in
maker.edges.equalTo(webView)
}
self.view.badlyDamagePic(hidden: true)
if Setting.getOyodo() != 1 {
Oyodo.attention().watch(data: Fleet.instance.shipWatcher) { (event: Event<Transform>) in
var show = false
Expand All @@ -86,7 +80,12 @@ class ViewController: UIViewController, UIScrollViewDelegate {
let battleFleet = Battle.instance.friendIndex
show = battleFleet >= 0 && Fleet.instance.isBadlyDamage(index: battleFleet)
}
badlyDamageWarning.isHidden = !show
if show == true {
self.view.badlyDamagePic(hidden: false)
} else {
self.view.badlyDamagePic(hidden: true)
}

if Setting.getwarningAlert() == 1 {
let warningAlert = UIAlertController(title: "⚠️ 大破 ⚠️", message: "あうぅっ! 痛いってばぁっ!\n(つД`)", preferredStyle: .alert)
warningAlert.addAction(UIAlertAction(title: "はい、はい、知っています", style: .destructive, handler: nil))
Expand Down Expand Up @@ -145,7 +144,23 @@ class ViewController: UIViewController, UIScrollViewDelegate {
}
}
}
settingBtn.addTarget(self, action: #selector(openSetting), for: .touchUpInside)
if #available(iOS 14.0, *) {
let settingAction = UIAction(
title: "開啓App設定"
) { (_) in
self.openSetting()
}
let appearanceAction = UIAction(
title: "開啓外觀設定"
) { (_) in
self.openAppearance()
}
let menuActions = [settingAction, appearanceAction]
settingBtn.showsMenuAsPrimaryAction = true
settingBtn.menu = UIMenu(title: "", children: menuActions)
} else {
settingBtn.addTarget(self, action: #selector(openSetting), for: .touchUpInside)
}

let refreshBtn = UIButton(type: .custom)
refreshBtn.setImage(UIImage(named: "reload.png"), for: .normal)
Expand All @@ -167,36 +182,49 @@ class ViewController: UIViewController, UIScrollViewDelegate {
maker.right.equalTo(settingBtn.snp.right)
maker.top.equalTo(settingBtn.snp.bottom)
}
refreshBtn.addTarget(self, action: #selector(confirmRefresh), for: .touchUpInside)

let appearanceBtn = UIButton(type: .custom)
if #available(iOS 13.0, *) {
let boldConfig = UIImage.SymbolConfiguration(weight: .bold)
appearanceBtn.setImage(UIImage(systemName: "pencil", withConfiguration: boldConfig), for: .normal)
appearanceBtn.tintColor = UIColor.white
} else {
appearanceBtn.setImage(UIImage(named: "refresh.png"), for: .normal)
}
appearanceBtn.imageEdgeInsets = UIEdgeInsets.init(top: 8, left: 8, bottom: 8, right: 8)
if Setting.getUseTheme() == 1 {
appearanceBtn.backgroundColor = UIColor.init(white: 0, alpha: 1)
if #available(iOS 14.0, *) {
let confirmAction = UIAction(
title: "確定"
) { (_) in
Setting.saveAttemptTime(value: 0)
self.reloadGame()
}
let menuActions = [confirmAction]
refreshBtn.showsMenuAsPrimaryAction = true
refreshBtn.menu = UIMenu(title: "確定重新整理?", children: menuActions)
} else {
appearanceBtn.backgroundColor = UIColor.init(white: 0.185, alpha: 1)
refreshBtn.addTarget(self, action: #selector(confirmRefresh), for: .touchUpInside)
}
self.view.addSubview(appearanceBtn)
appearanceBtn.snp.makeConstraints { maker in
if (screenSize == "5.4"){ //iPhone mini
maker.width.equalTo(35)
maker.height.equalTo(35)

if ProcessInfo().operatingSystemVersion.majorVersion < 14 {
let appearanceBtn = UIButton(type: .custom)
if #available(iOS 13.0, *) {
let boldConfig = UIImage.SymbolConfiguration(weight: .bold)
appearanceBtn.setImage(UIImage(systemName: "pencil", withConfiguration: boldConfig), for: .normal)
appearanceBtn.tintColor = UIColor.white
} else {
maker.width.equalTo(40)
maker.height.equalTo(40)
appearanceBtn.setImage(UIImage(named: "refresh.png"), for: .normal)
}
maker.centerX.equalTo(refreshBtn.snp.centerX)
maker.bottom.equalTo(view.snp.bottom).inset(20)
appearanceBtn.imageEdgeInsets = UIEdgeInsets.init(top: 8, left: 8, bottom: 8, right: 8)
if Setting.getUseTheme() == 1 {
appearanceBtn.backgroundColor = UIColor.init(white: 0, alpha: 1)
} else {
appearanceBtn.backgroundColor = UIColor.init(white: 0.185, alpha: 1)
}
self.view.addSubview(appearanceBtn)
appearanceBtn.snp.makeConstraints { maker in
if (screenSize == "5.4"){ //iPhone mini
maker.width.equalTo(35)
maker.height.equalTo(35)
} else {
maker.width.equalTo(40)
maker.height.equalTo(40)
}
maker.centerX.equalTo(refreshBtn.snp.centerX)
maker.bottom.equalTo(view.snp.bottom).inset(20)
}
appearanceBtn.addTarget(self, action: #selector(openAppearance), for: .touchUpInside)
}
appearanceBtn.addTarget(self, action: #selector(openAppearance), for: .touchUpInside)

Drawer().attachTo(controller: self)
}

Expand Down Expand Up @@ -306,6 +334,54 @@ class ViewController: UIViewController, UIScrollViewDelegate {
}
}

extension UIView {
func addBackground(imageName: String = "", contentMode: UIView.ContentMode = .scaleToFill) {
// setup the UIImageView
let backgroundImageView = UIImageView(frame: UIScreen.main.bounds)
backgroundImageView.image = UIImage(named: imageName)
backgroundImageView.contentMode = contentMode
backgroundImageView.translatesAutoresizingMaskIntoConstraints = false

addSubview(backgroundImageView)
sendSubviewToBack(backgroundImageView)

// adding NSLayoutConstraints
let leadingConstraint = NSLayoutConstraint(item: backgroundImageView, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1.0, constant: 0.0)
let trailingConstraint = NSLayoutConstraint(item: backgroundImageView, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0.0)
let topConstraint = NSLayoutConstraint(item: backgroundImageView, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0.0)
let bottomConstraint = NSLayoutConstraint(item: backgroundImageView, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0.0)

NSLayoutConstraint.activate([leadingConstraint, trailingConstraint, topConstraint, bottomConstraint])
}

func badlyDamagePic(hidden: Bool = true) {
// setup the UIImageView
let BDPImageView = UIImageView(frame: UIScreen.main.bounds)
BDPImageView.image = UIImage(named: "badly_damage_warning.png")
BDPImageView.translatesAutoresizingMaskIntoConstraints = false

if Setting.getBDPstatus() != true {
addSubview(BDPImageView)
BDPImageView.isHidden = true
// adding NSLayoutConstraints
let leadingConstraint = NSLayoutConstraint(item: BDPImageView, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1.0, constant: 0.0)
let trailingConstraint = NSLayoutConstraint(item: BDPImageView, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0.0)
let topConstraint = NSLayoutConstraint(item: BDPImageView, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0.0)
let bottomConstraint = NSLayoutConstraint(item: BDPImageView, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0.0)
NSLayoutConstraint.activate([leadingConstraint, trailingConstraint, topConstraint, bottomConstraint])
Setting.saveBDPstatus(value: true)
}

if hidden == true {
BDPImageView.isHidden = true
print("Hide BDPImageView")
} else if hidden == false {
BDPImageView.isHidden = false
print("Show BDPImageView")
}
}
}

extension UIDevice {

static let screenSize: String = {
Expand Down
6 changes: 3 additions & 3 deletions KanColleCommand/Widget/GripView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GripView: UIView {

public func gripTo(view: UIView) {
//backgroundColor = UIColor(white: 0.144, alpha: 1)
if Setting.getUseTheme() == 1 {
if Setting.getUseTheme() == 1 || Setting.getUseTheme() == 2 {
backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.8)
} else {
backgroundColor = UIColor(white: 0.185, alpha: 1)
Expand Down Expand Up @@ -67,13 +67,13 @@ class GripView: UIView {
public func selectItem(_ index: Int) {
for v in self.subviews {
if (v.tag == index) {
if Setting.getUseTheme() == 1 {
if Setting.getUseTheme() == 1 || Setting.getUseTheme() == 2 {
v.backgroundColor = UIColor(white: 0, alpha: 0)
} else {
v.backgroundColor = ViewController.DEFAULT_BACKGROUND
}
} else {
if Setting.getUseTheme() == 1 {
if Setting.getUseTheme() == 1 || Setting.getUseTheme() == 2 {
v.backgroundColor = UIColor(white: 0, alpha: 0)
} else {
v.backgroundColor = UIColor.clear
Expand Down

0 comments on commit 5220b6f

Please sign in to comment.