示例#1
0
 public ItemLibraryWindow(CampaignSave state, bool is_selector = false, string selection = null)
 {
     this.valid        = false;
     this.need_refresh = false;
     this.dirty        = false;
     this.state        = state;
     this.item_rows    = new List <ItemLibraryItemRow>();
     this.populate_item_rows(selection);
     this.selection      = null;
     this.container_rows = new List <ItemSpecContainerRow>();
     this.property_rows  = new List <ItemSpecPropertyRow>();
     InitializeComponent();
     this.item_list.ItemsSource      = this.item_rows;
     this.cat_box.ItemsSource        = this.categories;
     this.containers                 = new List <ContainerSpec>();
     this.container_list.ItemsSource = this.container_rows;
     this.properties                 = new Dictionary <string, string>();
     this.prop_list.ItemsSource      = this.property_rows;
     if (is_selector)
     {
         this.ok_but.Visibility  = Visibility.Visible;
         this.cancel_but.Content = "Cancel";
     }
     else
     {
         this.ok_but.Visibility  = Visibility.Collapsed;
         this.cancel_but.Content = "Done";
     }
 }
示例#2
0
        //TODO: ...

        //TODO: remove
        private void do_test(object sender, RoutedEventArgs e)
        {
            CampaignSave state = new CampaignSave(new Calendar(), new CharacterSheet());
            Guid         villain_id = Guid.NewGuid(), houserules_id = Guid.NewGuid();

            state.domain.topics[villain_id]    = new Topic("Baddy McVillainface", "This is the BBEG of the whole campaign, and a jerk-face.");
            state.domain.topics[houserules_id] = new Topic("House Rules", "House rules we use for this campaign.");
            state.domain.notes[Guid.NewGuid()] = new ExternalNote(
                "Polymorph preserves base HP, but adjusts total HP based on new Con mod.", DateTime.Now, new HashSet <Guid>()
            {
                houserules_id
            }
                );
            TopicWindow tw = new TopicWindow(
                new Dictionary <Guid, List <EntityRow> >(), state.domain.topics, state, state.domain.state, 0, null, houserules_id
                )
            {
                Owner = this
            };

            tw.ShowDialog();
#if false
            if (!iw.valid)
            {
                return;
            }
            List <string> action_types = new List <string>();
            foreach (EntryAction action in iw.get_actions())
            {
                action_types.Add(action.GetType().ToString());
            }
            MessageBox.Show(String.Join(", ", action_types), "Actions", MessageBoxButton.OK);
#endif
        }
示例#3
0
        public void test_add_references()
        {
            Guid               inv_guid = Guid.NewGuid();
            ItemCategory       cat = new ItemCategory("Wealth", 1);
            ItemSpec           gp = new ItemSpec("GP", cat, 1, 0), gem = new ItemSpec("Gem", cat, 100, 1);
            ItemStack          gp_stack = new ItemStack(gp, 350), gem_stack = new ItemStack(gem, 3), big_stack = new ItemStack(gp, 700);
            List <EntryAction> actions = new List <EntryAction>()
            {
                new ActionInventoryCreate(inv_guid, "Some Inventory"),
                new ActionInventoryEntryAdd(inv_guid, null, Guid.NewGuid(), gp_stack),
                new ActionInventoryEntryAdd(inv_guid, null, Guid.NewGuid(), gem_stack),
                new ActionInventoryEntryAdd(inv_guid, null, Guid.NewGuid(), big_stack),
            };
            CampaignSave state = new CampaignSave(new Calendar(), new CharacterSheet());

            state.add_references(actions);
            Assert.AreEqual(state.categories.Count, 1);
            Assert.IsTrue(state.categories.ContainsKey("Wealth"));
            Assert.AreEqual(state.categories["Wealth"].element, cat);
            Assert.AreEqual(state.categories["Wealth"].ref_count, 2);
            Assert.AreEqual(state.items.Count, 2);
            Assert.IsTrue(state.items.ContainsKey("GP"));
            Assert.AreEqual(state.items["GP"].element, gp);
            Assert.AreEqual(state.items["GP"].ref_count, 2);
            Assert.IsTrue(state.items.ContainsKey("Gem"));
            Assert.AreEqual(state.items["Gem"].element, gem);
            Assert.AreEqual(state.items["Gem"].ref_count, 1);
        }
 public InventoryListControl(ActionCallback change_callback)
 {
     this.change_callback = change_callback;
     this.save_state      = null;
     this.state           = null;
     this.inventory_rows  = null;
     InitializeComponent();
 }
示例#5
0
 public void set_state(
     CampaignSave save_state,
     CampaignState state,
     decimal timestamp,
     Dictionary <Guid, Topic> topics       = null,
     Dictionary <Guid, int> topic_refs     = null,
     Dictionary <Guid, ExternalNote> notes = null
     )
 {
     this.topic_cache.Clear();
     if (topics is not null)
     {
         this.topics = topics;
     }
     else
     {
         this.topics = new Dictionary <Guid, Topic>(save_state.domain.topics);
     }
     if (topic_refs is not null)
     {
         this.topic_refs = topic_refs;
     }
     else
     {
         this.topic_refs = new Dictionary <Guid, int>(save_state.topic_refs);
     }
     if (notes is not null)
     {
         this.notes = notes;
     }
     else
     {
         this.notes = new Dictionary <Guid, ExternalNote>(save_state.domain.notes);
     }
     this.save_state = save_state;
     this.state      = state;
     this.now        = timestamp;
     this.populate_topic_rows();
     if (this.state is null)
     {
         this.add_but.IsEnabled               = false;
         this.rem_but.IsEnabled               = false;
         this.view_but.IsEnabled              = false;
         this.note_add_but.IsEnabled          = false;
         this.external_note_add_but.IsEnabled = false;
     }
     else
     {
         this.add_but.IsEnabled               = true;
         this.note_add_but.IsEnabled          = true;
         this.external_note_add_but.IsEnabled = true;
     }
 }
示例#6
0
 private void SceneChanged(VTOLScenes scenes)
 {
     buttonMade = false;
     if (scenes == VTOLScenes.Akutan || scenes == VTOLScenes.CustomMapBase) // If inside of a scene that you can fly in
     {
         StartCoroutine(main());
     }
     else if (scenes == VTOLScenes.ReadyRoom)
     {
         trueSave        = null;
         selectedVehicle = null;
     }
 }
 public void set_state(CampaignSave save_state, CampaignState state)
 {
     this.save_state = save_state;
     this.state      = state;
     if (this.state is null)
     {
         this.add_but.IsEnabled  = false;
         this.rem_but.IsEnabled  = false;
         this.view_but.IsEnabled = false;
         this.inventory_rows.Clear();
         return;
     }
     this.populate_inventory_rows();
     this.add_but.IsEnabled = true;
 }
示例#8
0
 public TopicListControl(ActionCallback change_callback, Guid?entry_guid = null)
 {
     this.change_callback = change_callback;
     this.entry_guid      = entry_guid;
     this.topics          = null;
     this.topic_refs      = null;
     this.notes           = null;
     this.save_state      = null;
     this.state           = null;
     this.now             = 0;
     this.topic_rows      = new List <TopicRow>();
     this.topic_cache     = new Dictionary <Guid, List <EntityRow> >();
     InitializeComponent();
     this.topic_list.ItemsSource = this.topic_rows;
 }
示例#9
0
 public MainWindow()
 {
     this.save_path           = null;
     this.state               = null;
     this.state_dirty         = false;
     this.entry_rows          = new ObservableCollection <EntryRow>();
     this.character_list      = new CharacterListControl(this.entry_action_callback);
     this.inventory_list      = new InventoryListControl(this.entry_action_callback);
     this.calendar_event_list = new CalendarEventListControl(this.entry_action_callback);
     this.task_list           = new TaskListControl(this.entry_action_callback);
     this.topic_list          = new TopicListControl(this.entry_action_callback);
     InitializeComponent();
     this.character_group.Content      = this.character_list;
     this.inventory_group.Content      = this.inventory_list;
     this.entries_list.ItemsSource     = this.entry_rows;
     this.calendar_event_group.Content = this.calendar_event_list;
     this.task_group.Content           = this.task_list;
     this.topic_group.Content          = this.topic_list;
 }
示例#10
0
        private void open_campaign(object sender, RoutedEventArgs e)
        {
            if (this.state_dirty)
            {
                string           msg    = "Do you want to save changes to " + (this.save_path ?? "Untitled") + "?";
                MessageBoxResult result = MessageBox.Show(msg, "Campaign Log", MessageBoxButton.YesNoCancel);
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
                if (result != MessageBoxResult.No)
                {
                    this.save_campaign();
                }
            }

            OpenFileDialog open_dialog = new OpenFileDialog()
            {
                DefaultExt    = ".cmp",
                Filter        = "Campaign Files|*.cmp|All Files|*.*",
                ValidateNames = true,
            };

            if (this.save_path is not null)
            {
                open_dialog.FileName = this.save_path;
            }
            if (open_dialog.ShowDialog() != true)
            {
                return;
            }
            this.save_path = open_dialog.FileName;

            DataContractSerializer serializer = new DataContractSerializer(typeof(CampaignSave));

            using (FileStream f = new FileStream(this.save_path, FileMode.Open)) {
                XmlDictionaryReader reader     = XmlDictionaryReader.CreateTextReader(f, new XmlDictionaryReaderQuotas());
                CampaignSave        save_state = (CampaignSave)(serializer.ReadObject(reader, true));
                this.state = save_state;
            }
            this.state_dirty = false;
            this.populate_campaign();
        }
示例#11
0
        public void test_add_reference()
        {
            ItemCategory cat = new ItemCategory("Wealth", 1);
            ItemSpec     gp = new ItemSpec("GP", cat, 1, 0), gem = new ItemSpec("Gem", cat, 100, 1);
            CampaignSave state = new CampaignSave(new Calendar(), new CharacterSheet());

            state.add_item_reference(gp);
            Assert.AreEqual(state.categories.Count, 1);
            Assert.IsTrue(state.categories.ContainsKey("Wealth"));
            Assert.AreEqual(state.categories["Wealth"].element, cat);
            Assert.AreEqual(state.categories["Wealth"].ref_count, 1);
            Assert.AreEqual(state.items.Count, 1);
            Assert.IsTrue(state.items.ContainsKey("GP"));
            Assert.AreEqual(state.items["GP"].element, gp);
            Assert.AreEqual(state.items["GP"].ref_count, 1);

            state.add_item_reference(gem);
            Assert.AreEqual(state.categories.Count, 1);
            Assert.IsTrue(state.categories.ContainsKey("Wealth"));
            Assert.AreEqual(state.categories["Wealth"].element, cat);
            Assert.AreEqual(state.categories["Wealth"].ref_count, 2);
            Assert.AreEqual(state.items.Count, 2);
            Assert.IsTrue(state.items.ContainsKey("GP"));
            Assert.AreEqual(state.items["GP"].element, gp);
            Assert.AreEqual(state.items["GP"].ref_count, 1);
            Assert.IsTrue(state.items.ContainsKey("Gem"));
            Assert.AreEqual(state.items["Gem"].element, gem);
            Assert.AreEqual(state.items["Gem"].ref_count, 1);

            state.add_item_reference(gp);
            Assert.AreEqual(state.categories.Count, 1);
            Assert.IsTrue(state.categories.ContainsKey("Wealth"));
            Assert.AreEqual(state.categories["Wealth"].element, cat);
            Assert.AreEqual(state.categories["Wealth"].ref_count, 2);
            Assert.AreEqual(state.items.Count, 2);
            Assert.IsTrue(state.items.ContainsKey("GP"));
            Assert.AreEqual(state.items["GP"].element, gp);
            Assert.AreEqual(state.items["GP"].ref_count, 2);
            Assert.IsTrue(state.items.ContainsKey("Gem"));
            Assert.AreEqual(state.items["Gem"].element, gem);
            Assert.AreEqual(state.items["Gem"].ref_count, 1);
        }
示例#12
0
 public TopicWindow(
     Dictionary <Guid, List <EntityRow> > topic_cache,
     Dictionary <Guid, Topic> topics,
     CampaignSave save_state,
     CampaignState state,
     decimal now,
     Guid?entry_guid = null,
     Guid?guid       = null
     )
 {
     this.valid       = false;
     this.topic_cache = topic_cache;
     this.topics      = new Dictionary <Guid, Topic>(topics);
     this.save_state  = save_state;
     this.state       = state.copy();
     this.now         = now;
     this.entry_guid  = entry_guid;
     this.actions     = new List <EntryAction>();
     this.notes       = new Dictionary <Guid, ExternalNote>(save_state.domain.notes);
     this.topic_refs  = new Dictionary <Guid, int>();
     this.history     = new Stack <Guid>();
     if (guid is null)
     {
         if (entry_guid is null)
         {
             throw new ArgumentNullException(nameof(entry_guid));
         }
         this.guid = Guid.NewGuid();
         this.topics[this.guid] = new Topic("");
     }
     else
     {
         this.guid = guid.Value;
     }
     if (topic_cache.Count <= 0)
     {
         this.populate_topic_cache();
     }
     InitializeComponent();
     this.set_topic(this.guid);
 }
示例#13
0
        private void new_campaign(object sender, RoutedEventArgs e)
        {
            if (this.state_dirty)
            {
                string           msg    = "Do you want to save changes to " + (this.save_path ?? "Untitled") + "?";
                MessageBoxResult result = MessageBox.Show(msg, "Campaign Log", MessageBoxButton.YesNoCancel);
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
                if (result != MessageBoxResult.No)
                {
                    this.save_campaign();
                }
            }

            CampaignPropsWindow props_window = new CampaignPropsWindow()
            {
                Owner = this
            };

            props_window.ShowDialog();
            if (!props_window.valid)
            {
                return;
            }

            Calendar       cal;
            CharacterSheet char_sheet;

            try {
                cal        = props_window.get_calendar();
                char_sheet = props_window.get_character_sheet();
            }
            catch (InvalidOperationException) { return; }

            this.state       = new CampaignSave(cal, char_sheet);
            this.state_dirty = false;
            this.save_path   = null;
            this.populate_campaign();
        }
示例#14
0
 public static bool Prefix(ref CampaignSave __result, string campaignID)
 {
     if (!(VTOLAPI.currentScene == VTOLScenes.VehicleConfiguration) || AEAT.trueSave == null)
     {
         //Debug.Log("Not spoofing this save.");
         return(true);
     }
     Debug.Log(AEAT.trueSave.campaignID + " will be used as a campaign save.");
     __result = AEAT.trueSave;
     if (!AEAT.buttonMade)
     {
         Debug.Log(AEAT.path + " is AEAT.path");
         VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath = "hpequips/" + AEAT.path;
         LoadoutConfigurator config = Resources.FindObjectsOfTypeAll <LoadoutConfigurator>()[0];
         config.wm.resourcePath = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath;
         PilotSaveManager.currentVehicle.equipsResourcePath = "hpequips/" + AEAT.path;
         List <string> marsh      = new List <string>();
         List <GameObject> ketkev = new List <GameObject>();
         foreach (var gameobject in Resources.LoadAll <GameObject>("hpequips/" + AEAT.path))
         {
             if (!AllowedEquips.allowedEquips.Contains(gameobject.name))
             {
                 //Debug.Log("Unauthorized gameobject " + gameobject.name);
                 continue;
             }
             marsh.Add(gameobject.name);
             ketkev.Add(gameobject);
         }
         Traverse.Create(config).Field("unlockedWeaponPrefabs").SetValue(new Dictionary <string, EqInfo>());
         Traverse.Create(config).Field("allWeaponPrefabs").SetValue(new Dictionary <string, EqInfo>());
         config.lockedHardpoints = new List <int>();
         VTResources.GetScenario(PilotSaveManager.currentScenario.scenarioID, PilotSaveManager.currentCampaign).allowedEquips = marsh;
         __result.availableWeapons = marsh;
         Debug.Log("Set allowedEquips.");
         PilotSaveManager.currentVehicle.allEquipPrefabs = ketkev; // Don't need to reinit the config because this is prefixing the init statement
     }
     return(false);
 }
示例#15
0
        public void test_serialization()
        {
            Character    chr = new Character("Somebody");
            CampaignSave foo = new CampaignSave(new Calendar(), new CharacterSheet()), bar;

            Guid chr_guid = foo.domain.state.characters.add_character(chr);

            DataContractSerializer fmt = new DataContractSerializer(typeof(CampaignSave));

            using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) {
                fmt.WriteObject(ms, foo);
                ms.Seek(0, System.IO.SeekOrigin.Begin);
                System.Xml.XmlDictionaryReader xr = System.Xml.XmlDictionaryReader.CreateTextReader(ms, new System.Xml.XmlDictionaryReaderQuotas());
                bar = (CampaignSave)(fmt.ReadObject(xr, true));
            }
            Assert.AreEqual(foo.domain.state.characters.characters.Count, bar.domain.state.characters.characters.Count);
            Assert.IsTrue(bar.domain.state.characters.characters.ContainsKey(chr_guid));
            Assert.AreEqual(bar.domain.state.characters.characters[chr_guid].name, "Somebody");
            Assert.AreEqual(foo.calendar.GetType(), bar.calendar.GetType());
            Assert.AreEqual(foo.character_sheet.GetType(), bar.character_sheet.GetType());
            Assert.AreEqual(foo.show_past_events, bar.show_past_events);
            Assert.AreEqual(foo.show_inactive_tasks, bar.show_inactive_tasks);
        }