Mercurial > repos > WarFoundryForge
comparison FrmSystem.cs @ 16:489d36b167a6
Added Up and Down buttons for Stat Lines tab
Fixed Category and Stat List from not removing the last one
author | Tsudico |
---|---|
date | Wed, 22 Dec 2010 19:58:51 -0600 |
parents | 3a347947ecea |
children |
comparison
equal
deleted
inserted
replaced
15:3a347947ecea | 16:489d36b167a6 |
---|---|
181 currentStats = null; | 181 currentStats = null; |
182 } | 182 } |
183 | 183 |
184 private void updateCategoryList() | 184 private void updateCategoryList() |
185 { | 185 { |
186 this.listCategories.Items.Clear(); | |
186 if (system.Categories.Length > 0) | 187 if (system.Categories.Length > 0) |
187 { | 188 { |
188 this.listCategories.Items.Clear(); | |
189 for (int i = 0; i < system.Categories.Length; i++) | 189 for (int i = 0; i < system.Categories.Length; i++) |
190 { | 190 { |
191 this.listCategories.Items.Add(system.Categories[i].Name); | 191 this.listCategories.Items.Add(system.Categories[i].Name); |
192 } | 192 } |
193 } | 193 } |
574 void lviewStats_SelectedIndexChanged(object sender, System.EventArgs e) | 574 void lviewStats_SelectedIndexChanged(object sender, System.EventArgs e) |
575 { | 575 { |
576 currentStats = null; | 576 currentStats = null; |
577 foreach(IBBoard.WarFoundry.API.Objects.SystemStats stat in system.SystemStats) | 577 foreach(IBBoard.WarFoundry.API.Objects.SystemStats stat in system.SystemStats) |
578 { | 578 { |
579 ListView.SelectedListViewItemCollection items = this.lviewStats.SelectedItems; | 579 foreach(ListViewItem item in this.lviewStats.SelectedItems) |
580 if(items.Count > 0) | |
581 { | |
582 this.btnStatsRemove.Enabled = true; | |
583 } | |
584 foreach(ListViewItem item in items) | |
585 { | 580 { |
586 if(stat.ID == item.Text) | 581 if(stat.ID == item.Text) |
587 { | 582 { |
583 if(this.lviewStats.Items.Count > 0) | |
584 { | |
585 this.btnStatsRemove.Enabled = true; | |
586 } | |
588 currentStats = new IBBoard.WarFoundry.API.Objects.SystemStats(stat.ID); | 587 currentStats = new IBBoard.WarFoundry.API.Objects.SystemStats(stat.ID); |
589 foreach(IBBoard.WarFoundry.API.Objects.StatSlot slot in stat.StatSlots) | 588 foreach(IBBoard.WarFoundry.API.Objects.StatSlot slot in stat.StatSlots) |
590 { | 589 { |
591 currentStats.AddStatSlot(slot.Name); | 590 currentStats.AddStatSlot(slot.Name); |
592 } | 591 } |
596 } | 595 } |
597 else | 596 else |
598 { | 597 { |
599 this.btnStatsDefault.Enabled = true; | 598 this.btnStatsDefault.Enabled = true; |
600 } | 599 } |
600 if (item.Index == 0) | |
601 { | |
602 this.btnStatsUp.Enabled = false; | |
603 } | |
604 else | |
605 { | |
606 this.btnStatsUp.Enabled = true; | |
607 } | |
608 if (item.Index == this.lviewStats.Items.Count - 1) | |
609 { | |
610 this.btnStatsDown.Enabled = false; | |
611 } | |
612 else | |
613 { | |
614 this.btnStatsDown.Enabled = true; | |
615 } | |
601 this.txtStatLineID.Text = currentStats.ID; | 616 this.txtStatLineID.Text = currentStats.ID; |
602 this.txtStatName.Enabled = true; | 617 this.txtStatName.Enabled = true; |
603 updateStatNames(currentStats); | 618 updateStatNames(currentStats); |
604 updateStatLinePreview(currentStats); | 619 updateStatLinePreview(currentStats); |
605 } | 620 } |
638 { | 653 { |
639 system.StandardSystemStatsID = this.lviewStats.SelectedItems[0].Text; | 654 system.StandardSystemStatsID = this.lviewStats.SelectedItems[0].Text; |
640 updateSystemStatsList(); | 655 updateSystemStatsList(); |
641 } | 656 } |
642 | 657 |
658 private void btnStatsUp_Click(object sender, EventArgs e) | |
659 { | |
660 int index = this.lviewStats.SelectedIndices[0]; | |
661 IBBoard.WarFoundry.API.Objects.SystemStats[] statsList = new IBBoard.WarFoundry.API.Objects.SystemStats[this.lviewStats.Items.Count]; | |
662 | |
663 for (int i = 0; i < system.SystemStats.Length; i++) | |
664 { | |
665 statsList[i] = system.SystemStats[i]; | |
666 } | |
667 foreach (IBBoard.WarFoundry.API.Objects.SystemStats stat in system.SystemStats) | |
668 { | |
669 system.RemoveSystemStats(stat.ID); | |
670 } | |
671 | |
672 IBBoard.WarFoundry.API.Objects.SystemStats temp = statsList[index]; | |
673 statsList[index] = statsList[index - 1]; | |
674 statsList[index - 1] = temp; | |
675 | |
676 for (int i = statsList.Length - 1; i >= 0; i--) | |
677 { | |
678 system.AddSystemStats(statsList[i]); | |
679 } | |
680 | |
681 updateSystemStatsList(); | |
682 this.lviewStats.Items[index - 1].Selected = true; | |
683 } | |
684 | |
685 private void btnStatsDown_Click(object sender, EventArgs e) | |
686 { | |
687 int index = this.lviewStats.SelectedIndices[0]; | |
688 IBBoard.WarFoundry.API.Objects.SystemStats[] statsList = new IBBoard.WarFoundry.API.Objects.SystemStats[this.lviewStats.Items.Count]; | |
689 | |
690 for (int i = 0; i < system.SystemStats.Length; i++) | |
691 { | |
692 statsList[i] = system.SystemStats[i]; | |
693 } | |
694 foreach (IBBoard.WarFoundry.API.Objects.SystemStats stat in system.SystemStats) | |
695 { | |
696 system.RemoveSystemStats(stat.ID); | |
697 } | |
698 | |
699 IBBoard.WarFoundry.API.Objects.SystemStats temp = statsList[index]; | |
700 statsList[index] = statsList[index + 1]; | |
701 statsList[index + 1] = temp; | |
702 | |
703 for (int i = statsList.Length - 1; i >= 0; i--) | |
704 { | |
705 system.AddSystemStats(statsList[i]); | |
706 } | |
707 | |
708 updateSystemStatsList(); | |
709 this.lviewStats.Items[index + 1].Selected = true; | |
710 } | |
711 | |
643 private void txtStatLineID_TextChanged(object sender, EventArgs e) | 712 private void txtStatLineID_TextChanged(object sender, EventArgs e) |
644 { | 713 { |
645 if(this.txtStatLineID.Text != string.Empty) | 714 if(this.txtStatLineID.Text != string.Empty) |
646 { | 715 { |
647 this.btnStatsAdd.Enabled = true; | 716 this.btnStatsAdd.Enabled = true; |