From 693650a4b5c4474cb27b352a473cd816b2799172 Mon Sep 17 00:00:00 2001 From: Jayvant Javier Pujara Date: Sun, 2 Dec 2012 05:50:34 -0500 Subject: [PATCH] Combine subproj w/ project man. --- About.ahk | 2 +- Hotkeys.ahk | 4 ++-- Main.ahk | 1 - ProjectComplete.ahk | 15 +++++++++------ ProjectManage.ahk | 41 +++++++++++++++++++++++++++++++++------- ProjectRemove.ahk | 1 + ProjectsView.ahk | 46 ++++++++++++++++++++++++++++++++++++++++++--- Settings.ahk | 2 +- SkillsView.ahk | 5 ++--- 9 files changed, 93 insertions(+), 24 deletions(-) diff --git a/About.ahk b/About.ahk index 64409d9..5bb1d4c 100644 --- a/About.ahk +++ b/About.ahk @@ -16,7 +16,7 @@ SiteUrl := "http://www.reddit.com/r/LifeRPG/" Gui, AboutBox:Add, Picture, w32 h-1, res/WP_RPG_VG.ico Gui, AboutBox:Font, bold -Gui, AboutBox:Add, Text, x+10, LifeRPG r2 +Gui, AboutBox:Add, Text, x+10, LifeRPG 3 Gui, AboutBox:Font Gui, AboutBox:Add, Text, y+1, by Jayvant Javier Pujara diff --git a/Hotkeys.ahk b/Hotkeys.ahk index c39561f..044d4eb 100644 --- a/Hotkeys.ahk +++ b/Hotkeys.ahk @@ -58,8 +58,8 @@ If (SelectedProjectID == "ID") } else { - StringTrimLeft, NewConfidence, A_ThisHotkey, 1 - db.Query("UPDATE projects SET confidence = " NewConfidence " WHERE id = " SelectedProjectID ) + StringTrimLeft, NewDifficulty, A_ThisHotkey, 1 + db.Query("UPDATE projects SET difficulty = " NewDifficulty " WHERE id = " SelectedProjectID ) gosub FilterUpdate ;UpdateList(Selection, FilterImportanceSelected, FilterSkillSelected) return diff --git a/Main.ahk b/Main.ahk index 0d2d90e..3718fdc 100644 --- a/Main.ahk +++ b/Main.ahk @@ -30,7 +30,6 @@ SetBatchLines -1 #Include ProjectManage.ahk #Include ProjectRemove.ahk #Include ProjectComplete.ahk -#Include SubprojectAdd.ahk #Include SkillsView.ahk #Include ProjectLog.ahk #Include ProfileEdit.ahk diff --git a/ProjectComplete.ahk b/ProjectComplete.ahk index 0e0cb1e..e6d9b52 100644 --- a/ProjectComplete.ahk +++ b/ProjectComplete.ahk @@ -2,6 +2,7 @@ ;~ Confirm Project completion: CompleteProject: +Gui, ListView, MainList Selection := LV_GetNext("","F") LV_GetText(SelectedProjectID, Selection, 1) LV_GetText(ProjectCompletionState, Selection, 2) @@ -46,7 +47,7 @@ return CompleteProject(SelectedProjectID) { - global db, Difficulties, Awards + global db, DifficultyLevels, AwardLevels ; Get the difficulty to know how many points to award and the skill to show in notification CompletedProject := db.OpenRecordSet("SELECT * FROM projects WHERE id = " SelectedProjectID) while (!CompletedProject.EOF) @@ -58,8 +59,9 @@ CompleteProject(SelectedProjectID) CompletedProject.Close() ; Mark project as done: - db.Query("UPDATE projects SET difficulty = 'Done', importance = '', dateDone = " . A_Now . ", levelDone = " . LevelGet() . " WHERE id = " SelectedProjectID) + db.Query("UPDATE projects SET difficulty = 0, importance = '', dateDone = " . A_Now . ", levelDone = " . LevelGet() . " WHERE id = " SelectedProjectID) + /* ; Get the level count for the skill if the project has one: if (SkillToIncrease) { @@ -71,18 +73,19 @@ CompleteProject(SelectedProjectID) SkillLevel := row[A_index] } } + */ ; Get the amount of points to award for the chosen level - for Num, Difficulty in Difficulties + for Num, Difficulty in DifficultyLevels { - if (DifficultyToAward = Difficulty) - for Key, Award in Awards + if (DifficultyToAward = Num) + for Key, Award in AwardLevels { if (Num = Key) AwardGiven := Award } } - UpdateProgress(DifficultyToAward . " Achievement", AwardGiven) + UpdateProgress(DifficultyLevels[DifficultyToAward] . " Achievement", AwardGiven) if (SkillToIncrease) Notification("SKILL INCREASED", SkillToIncrease . " increased to " . SkillLevel) } \ No newline at end of file diff --git a/ProjectManage.ahk b/ProjectManage.ahk index 7e6b575..0e95fea 100644 --- a/ProjectManage.ahk +++ b/ProjectManage.ahk @@ -19,6 +19,12 @@ Action := "Add" ProjectManage(Action) return +; Add a new subproject: +AddSubproject: +Action := "Subproject" +ProjectManage(Action) +return + ; Edit a selected project: EditProject: Action := "Edit" @@ -116,13 +122,17 @@ if (ProjectSkillEdit = "All" || ProjectSkillEdit = "None") ; Sort this out durin MsgBox, 8192, Error, "All" and "None" can't be used as skill names! return } -if (Action = "Add" || Action = "QuickDone" || Action = "QuickAdd") +if (Action = "Add" || Action = "QuickDone" || Action = "QuickAdd" || Action = "Subproject") { Record := {} Record.Project := ProjectNameEdit Record.Difficulty := KeyGet(DifficultyLevels, ProjectDifficultyEdit) Record.Importance := KeyGet(ImportanceLevels, ProjectImportanceEdit) Record.dateEntered := A_Now + if (Action = "Subproject") + { + Record.Parent := SelectedProjectID + } db.Insert(Record, "projects") @@ -174,7 +184,6 @@ else if (Action = "QuickAdd" || Action = "QuickDone") } gosub FilterUpdate RefreshSkillsList(FilterSkillSelected) -return ; Fall through below to close window. ProjectManagerGuiEscape: @@ -185,7 +194,7 @@ try for k, v in SkillACStopKeys Hotkey, %v%, Off } -if (Action = "Add" || Action = "Edit") +if (Action = "Add" || Action = "Edit" || Action = "Subproject") { GuiChildClose("ProjectManager") } @@ -228,13 +237,14 @@ DBGetVal(Query, Val) ProjectManage(Action) { global + Gui, ListView, MainList ProjectNameEdit = ProjectDifficultyEdit = ProjectSkillEdit = ; Get the row number of the selected project from the main project ListView: Selection := LV_GetNext("","F") - ; If editing, get the ID number of that project: - if (Action = "Edit") + ; If editing or adding subproject, get the ID number of that project: + if (Action = "Edit" || Action = "Subproject") { LV_GetText(SelectedProjectID, Selection, 1) ; Get project ID number from hidden column of ListView ; If no row is selected and edit is called, do nothing and go back: @@ -275,9 +285,17 @@ ProjectManage(Action) ProjectSkill = ProjectImportance = } + if (Action = "Subproject") + { + ; Temporary, working on where (if) to include parent project name in subproject-add box): + ProjectName = + ProjectDifficulty = + ProjectSkill = + ProjectImportance = + } ; Build the GUI window to either add or edit a project: ; Initiate a modal child window owned by the main window (by default): - if (Action = "Add" || Action = "Edit") + if (Action = "Add" || Action = "Edit" || Action = "Subproject") GuiChildInit("ProjectManager") else if (Action = "QuickDone" || Action = "QuickAdd") { @@ -322,6 +340,15 @@ ProjectManage(Action) StringReplace, PMTitle, Action, add, Add else PMTitle := Action - Gui, ProjectManager:Show, w%Width% h%Height% x%xc% y%yc%, %PMTitle% Project + if (Action = "QuickAdd" || Action = "QuickDone") + Gui, ProjectManager:Show, w%Width% h%Height%, %PMTitle% Project + else + Gui, ProjectManager:Show, w%Width% h%Height% x%xc% y%yc%, %PMTitle% Project + ; Remove the skill auto-complete tooltip if LifeRPG window loses focus: + SetTimer, ACWinWatch, 300 + return + ACWinWatch: + if !WinActive("ahk_class AutoHotkeyGUI") + SkillACShutOff() return } \ No newline at end of file diff --git a/ProjectRemove.ahk b/ProjectRemove.ahk index 8917b6a..7792f80 100644 --- a/ProjectRemove.ahk +++ b/ProjectRemove.ahk @@ -2,6 +2,7 @@ ;~ Confirm project deletion/removal: RemoveProject: +Gui, ListView, MainList Selection := LV_GetNext("","F") LV_GetText(SelectedProjectID, Selection, IDCol) If (SelectedProjectID == "ID") diff --git a/ProjectsView.ahk b/ProjectsView.ahk index f85853c..8e91414 100644 --- a/ProjectsView.ahk +++ b/ProjectsView.ahk @@ -36,14 +36,20 @@ GuiControl, , FilterSkill, % ListSkills() Gui, Add, Checkbox, vFilterShowDone gFilterUpdate x+10, Show do&ne +; Sidelist: +SideListWidth = 200 +Gui, Add, ListView, x0 y+15 r20 AltSubmit -Multi vSideList -Hdr, ID|Diff|Parent + ;~ ListView: -Gui, Add, ListView, x0 y+15 r20 Grid AltSubmit -Multi Count%CountUp% vMainList hwndColored_LV_1, ID|DifficultyID|ImportanceID|ParentID|ColorID|Difficulty|Project|Importance|Parent +Gui, Add, ListView, x+1 r20 AltSubmit -Multi Count%CountUp% vMainList hwndColored_LV_1, ID|DifficultyID|ImportanceID|ParentID|ColorID|Difficulty|Project|Importance|Parent } Colored_LV_1_BG = 5 ;ColorIDCol GuiControl, Focus, SearchQuery ; Focus on search bar by default Gui, Show, w827 h600, %AppTitle% ; Show the GUI we've created UpdateList() ; Show all projects Gui, +Resize +MinSize621x ; Make GUI resizable + + return ;~ =============================================================================== @@ -53,7 +59,8 @@ GuiSize: if A_EventInfo = 1 ; The window has been minimized. No action needed. return ; Otherwise, the window has been resized or maximized. Resize the controls to match. -GuiControl, Move, Mainlist, % "H" . (A_GuiHeight - 55) . " W" . (A_GuiWidth) +GuiControl, Move, Sidelist, % "H" . (A_GuiHeight - 55) . " W" . (SideListWidth := A_GuiWidth * .35) +GuiControl, Move, Mainlist, % "H" . (A_GuiHeight - 55) . " W" . (A_GuiWidth - (SideListWidth + 5)) . " X" . (SideListWidth+5) ; Resize search bar to fit dropdown filter controls: if (A_GuiWidth > 811) ;827) { @@ -200,6 +207,7 @@ UpdateList(NextSelection="", DifficultySelected="All", Skill="All") Critical Gui, 1:Default + Gui, ListView, MainList GuiControlGet, SearchString, , SearchQuery GuiControl, -ReDraw, MainList LV_Delete() @@ -225,7 +233,7 @@ UpdateList(NextSelection="", DifficultySelected="All", Skill="All") if (FilterShowDone = 1) Filter .= "Difficulty = 0 or Difficulty is null " else - Filter .= "Difficulty is not null " + Filter .= "difficulty <> 0 " ; Difficulty level if (DifficultySelected <> "All") @@ -330,5 +338,37 @@ UpdateList(NextSelection="", DifficultySelected="All", Skill="All") ; Enable ListView coloring: OnMessage( WM_NOTIFY := 0x4E, "WM_NOTIFY" ) GuiControl, +ReDraw, MainList + UpdateSideList() return +} + +UpdateSidelist() +{ + global + ParentIDCol = 1 + ParentDiffCol = 2 + ParentNameCol = 3 + Gui, 1:Default + Gui, ListView, SideList + GuiControl, -ReDraw, SideList + LV_Delete() + ParentProjectList := db.OpenRecordSet("SELECT * FROM projects WHERE id IN (SELECT parent FROM projects WHERE difficulty <> 0)") + while (!ParentProjectList.EOF) + { + ParentID := ParentProjectList["id"] + ParentDiff := ParentProjectList["difficulty"] + ParentName := ParentProjectList["project"] + + LV_Add("", ParentID, ParentDiff, ParentName) + ParentProjectList.MoveNext() + } + ParentProjectList.Close() + LV_ModifyCol(ParentNameCol, "sort") + LV_Insert(1, "", 0, 0, "All") ; To show all projects, ID shall be 0 (zero) + LV_ModifyCol() + Loop % LV_GetCount("Col") + LV_Modify(A_Index, "AutoHDR") + LV_ModifyCol(ParentIDCol, 0) + LV_ModifyCol(ParentDiffCol, 0) + GuiControl, +ReDraw, SideList } \ No newline at end of file diff --git a/Settings.ahk b/Settings.ahk index 2ce94c0..5f21fd3 100644 --- a/Settings.ahk +++ b/Settings.ahk @@ -19,7 +19,7 @@ AwardLevels := [5, 10, 25] Colors := [BGR("ADFF2F"), BGR("FFD700"), BGR("FF6347")] ;~ Priorities: -ImportanceLevels := ["High", "Medium", "Low"] +ImportanceLevels := ["Very High", "High", "Medium", "Low"] BGR(RGB) { diff --git a/SkillsView.ahk b/SkillsView.ahk index 150f9d6..d816150 100644 --- a/SkillsView.ahk +++ b/SkillsView.ahk @@ -14,16 +14,15 @@ SVy := CenterY(SVh) ; Populate the Skill Stats ListView with skills and stats: ; 1. Get the skills count for all done items from the projects table ; First we need to add all skills to the LV -; SELECT DISTINCT skill FROM projects WHERE difficulty <> 'Done' ORDER BY skill ; 2. Add to ListView -SkillsList := db.OpenRecordSet("SELECT DISTINCT skill FROM projects WHERE skill IS NOT NULL AND skill <> '' ORDER BY skill") +SkillsList := db.OpenRecordSet("SELECT DISTINCT skill FROM skills ORDER BY skill") while (!SkillsList.EOF) { SkillListName := SkillsList["skill"] LV_Add("", SkillListName) RowNum := A_Index - Table := db.Query("SELECT COUNT(skill) FROM projects WHERE skill = '" . SkillListName . "' AND confidence is null") + Table := db.Query("SELECT COUNT(id) FROM projects WHERE id IN (SELECT projectID FROM skills WHERE skill = '" . SkillListName . "') AND difficulty = 0") columnCount := Table.Columns.Count() for each, row in Table.Rows {