예제 #1
0
        private async void importEdit_Click(object sender, RoutedEventArgs e)
        {
            //open up windows dialog to pick file
            FileOpenPicker picker = new FileOpenPicker();

            picker.FileTypeFilter.Add(".json");
            picker.FileTypeFilter.Add(".agf");
            picker.ViewMode = PickerViewMode.List;

            StorageFile file = await picker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }


            string contents = "";

            try
            {
                contents = await UWPIO.storageFileToString(file);

                game = new ActiveGame(AdventureGame.loadFromString(contents));
            } catch (Exception x)
            {
                await new MessageDialog("Invalid Adventuregame Selected", "Error").ShowAsync();
                return;
            }

            refresh();
        }
예제 #2
0
        public Creator()
        {
            game = new ActiveGame(AdventureGame.loadFromString(DEF_GAME_TXT));
            game.start();

            currentState = game.data.states[game.position];

            this.InitializeComponent();
            refresh();
        }
예제 #3
0
        //when a dude is clicked on a play button should appear, and when they're unclicked it should disappear

        private async void UpdateFiles()
        {
            List <string> files = await UWPIO.listFiles(UWPIO.GAMEDIR);

            foreach (string file in files)
            {
                // Limit to only json or agf files.
                int l = file.Length;
                if (file.Substring(l - 5) == ".json" || file.Substring(l - 4) == ".agf")
                {
                    string        fname = UWPIO.GAMEDIR + "\\" + file;
                    AdventureGame ag    = AdventureGame.loadFromString(await UWPIO.readFile(fname));
                    Games.Add(new GameInfo(ag.title, ag.author, file,
                                           await UWPIO.dateCreatedAsync(fname),
                                           await UWPIO.dateModifiedAsync(fname)));
                }
            }
        }
예제 #4
0
        private async void ImportButton_Click(object sender, RoutedEventArgs e)
        {
            //open up windows dialog to pick file
            FileOpenPicker picker = new FileOpenPicker();

            picker.FileTypeFilter.Add(".json");
            picker.FileTypeFilter.Add(".agf");
            picker.ViewMode = PickerViewMode.List;

            StorageFile file = await picker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }


            string contents = "";

            try
            {
                contents = await UWPIO.storageFileToString(file);

                loadedGame = AdventureGame.loadFromString(contents);
            } catch (Exception x)
            {
                await new MessageDialog("Invalid Adventuregame Selected", "Error").ShowAsync();
                return;
            }

            title       = loadedGame.title;
            author      = loadedGame.author;
            gamevars    = loadedGame.gamevars.ToString();
            start_state = loadedGame.start_state;

            fileContents = contents;
            currentPath  = file.Path;
            curFile      = file;

            updateDisplay();
        }
예제 #5
0
        //option click handler
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            //depending on who entered, we do different things
            dynamic g = e.Parameter;

            if (g is ActiveGame)
            {
                game = g;
            }
            else
            {
                //load from path
                dynamic       btn       = e.Parameter;
                string        file_path = btn.Tag;
                AdventureGame ag        = AdventureGame.loadFromString(await UWPIO.readFile(UWPIO.GAMEDIR + "\\" + file_path));
                game = new ActiveGame(ag);
                game.start();
            }

            base.OnNavigatedTo(e);

            refresh();
        }