Exemple #1
0
        public string CreateNewTextVersion(TextResource textResource, string text)
        {
            var fulltextClient = m_communicationProvider.GetFulltextServiceClient();
            var externalTextId = fulltextClient.CreateTextResource(text, textResource.VersionNumber);

            return(externalTextId);
        }
        /// <summary>
        /// To run this application, the following is required:
        ///
        /// - API token key/secret from Account -> Developer -> API Tokens
        /// - A verified Phone Number UUID from Account -> Telephony -> Phone Numbers -> Edit (in the URI)
        /// - Fill in variables to run example
        /// </summary>
        /// <param name="args"></param>
        async static Task Main(string[] args)
        {
            var tokenKey    = "";
            var tokenSecret = "";

            // Set the Phone Number ID (e.g., GncieHvbCKfMYXmeycoWZm)
            var phoneNumberId = "";

            // Sample contact information to call
            var to = ""; // In E.164 format (such as +1xxxxxxxxx)

            // Initialize SDK
            OmnigageClient.Init(tokenKey, tokenSecret);

            var message = new TextMessageResource
            {
                Body = "Sample body"
            };
            await message.Create();

            var text = new TextResource
            {
                To          = to,
                TextMessage = message,
                PhoneNumber = new PhoneNumberResource
                {
                    Id = phoneNumberId
                }
            };

            await text.Create();
        }
Exemple #3
0
        public IList <MarkdownHeadingData> GetHeadingsFromPageText(TextResource textResource)
        {
            var text   = GetPageText(textResource, TextFormatEnumContract.Raw);
            var result = m_markdownHeadingAnalyzer.FindAllHeadings(text);

            return(result);
        }
        public TranslationResourceDictionary()
        {
            var indexFile = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Lang\index.txt");

            if (System.IO.File.Exists(indexFile))
            {
                var lines = System.IO.File.ReadAllLines(indexFile);
                foreach (var line in lines)
                {
                    var index = line.IndexOf("=");
                    if (index > 0)
                    {
                        var name  = line.Substring(0, index);
                        var value = line.Substring(index + 1);
                        if (name == Config.Instance.Language)
                        {
                            TextResource.Load(value);
                            foreach (var key in TextResource.GetKeys())
                            {
                                Add(key, TextResource.GetText(key));
                            }
                        }
                    }
                }
            }
        }
        void Awake()
        {
//            Debug.LogFormat("TextTranslationController {0}/{1}/{2}", resourceFileName, resourceFilter, resourceId);
            text = gameObject.GetComponent <TextMesh>();
            tr   = TextResource.Get(resourceFileName, resourceFilter);
            tr.OnResourceChanged += ChangeText;
        }
Exemple #6
0
        private PasswordDialog(Builder builder, Window parent, WindowGroup group) : base(builder.GetRawOwnedObject("dialog"))
        {
            builder.Autoconnect(this);

            Modal = true;
            SetPosition(WindowPosition.CenterAlways);
            TransientFor = parent;
            this.group   = group;
            this.group.AddWindow(this);

            GtkHelper.AttachSafeDispose(this);

            Label1.Text = TextResource.GetText("DESC_HOST");
            Label2.Text = TextResource.GetText("DESC_USER");
            Label3.Text = TextResource.GetText("DESC_PASS");

            BtnOk.Clicked     += BtnOk_Clicked;
            BtnCancel.Clicked += BtnCancel_Clicked;

            BtnOk.Label     = TextResource.GetText("MSG_OK");
            BtnCancel.Label = TextResource.GetText("ND_CANCEL");

            Title = TextResource.GetText("DESC_PASS");
            SetDefaultSize(400, 300);
        }
Exemple #7
0
    private void Awake()
    {
        _networkManager = NetworkManager.GetInstance();
        _textResource   = TextResource.GetInstance();
        _setting        = Setting.GetInstance();
        _networkManager.SocketOpen();
        _roomListLoader = new Timer();

        _isShowCreateRoom = false;
        _selectedRoom     = null;

        BtnShop.onClick.AddListener(OnClickBtnShop);
        BtnRank.onClick.AddListener(OnClickBtnRank);
        BtnInventory.onClick.AddListener(OnClickBtnInventory);
        BtnChat.onClick.AddListener(OnClickBtnChat);
        BtnShowCreateRoom.onClick.AddListener(OnClickBtnShowCreateRoom);
        BtnJoin.onClick.AddListener(OnClickBtnJoin);
        BtnShowFriends.onClick.AddListener(OnClickBtnShowFriends);
        BtnCreateRoom.onClick.AddListener(OnClickBtnCreateRoom);
        BtnShowCreateRoomClose.onClick.AddListener(OnClickBtnShowCreateRoomClose);
        BtnBack.onClick.AddListener(OnClickBtnBack);

        SetTextSize();
        SetTextValue();
        SetSocketEvents(_networkManager);
    }
        public AdvancedDownloadDialog(Builder builder, Window parent, WindowGroup group) : base(builder.GetRawOwnedObject("dialog"))// base(TextResource.GetText("DESC_ADV_TITLE"), parent, DialogFlags.Modal)
        {
            SetDefaultSize(550, 450);
            builder.Autoconnect(this);
            Title = TextResource.GetText("DESC_ADV_TITLE");
            Modal = true;
            SetPosition(WindowPosition.CenterAlways);
            TransientFor = parent;
            this.group   = group;
            this.group.AddWindow(this);

            GtkHelper.PopulateComboBox(CmbProxyType !,
                                       TextResource.GetText("NET_SYSTEM_PROXY"),
                                       TextResource.GetText("ND_NO_PROXY"),
                                       TextResource.GetText("ND_MANUAL_PROXY"));

            GtkHelper.ConfigurePasswordField(TxtPassword);
            GtkHelper.ConfigurePasswordField(TxtProxyPassword);
            TxtSpeedLimit !.Text    = "0";
            CmbProxyType !.Changed += CmbProxyType_Changed;

            btnOk.Clicked     += BtnOK_Click;
            btnCancel.Clicked += BtnCancel_Click;

            LoadTexts();

            GtkHelper.AttachSafeDispose(this);
        }
Exemple #9
0
        private QueueSelectionDialog(Builder builder, Window parent, WindowGroup group) : base(builder.GetRawOwnedObject("dialog"))
        {
            builder.Autoconnect(this);
            Modal = true;
            SetPosition(WindowPosition.CenterAlways);
            TransientFor = parent;
            this.group   = group;
            this.group.AddWindow(this);

            GtkHelper.AttachSafeDispose(this);
            Title = TextResource.GetText("Q_MOVE_TO");
            SetDefaultSize(400, 300);
            LoadTexts();

            listStore      = new ListStore(typeof(string));
            LbQueues.Model = listStore;

            var queueNameRendererText = new CellRendererText();
            var queueNameColumn       = new TreeViewColumn("", queueNameRendererText, "text", 0)
            {
                Resizable   = false,
                Reorderable = false,
                Sizing      = TreeViewColumnSizing.Autosize,
                Expand      = true
            };

            LbQueues.HeadersVisible = false;
            LbQueues.AppendColumn(queueNameColumn);

            BtnCancel.Clicked += BtnCancel_Clicked;
            BtnOK.Clicked     += BtnOK_Clicked;
        }
Exemple #10
0
 private void BtnOk_Clicked(object?sender, EventArgs e)
 {
     Result = true;
     if (string.IsNullOrEmpty(TxtName.Text))
     {
         GtkHelper.ShowMessageBox(this, TextResource.GetText("MSG_CAT_NAME_MISSING"));
         return;
     }
     if (string.IsNullOrEmpty(TxtFileTypes.Text))
     {
         GtkHelper.ShowMessageBox(this, TextResource.GetText("MSG_CAT_FILE_TYPES_MISSING"));
         return;
     }
     if (string.IsNullOrEmpty(TxtFolder.Text))
     {
         GtkHelper.ShowMessageBox(this, TextResource.GetText("MSG_CAT_FOLDER_MISSING"));
         return;
     }
     this.DisplayName = this.TxtName.Text;
     this.FileTypes   = this.TxtFileTypes.Text;
     this.Folder      = this.TxtFolder.Text;
     Result           = true;
     this.group.RemoveWindow(this);
     Dispose();
 }
Exemple #11
0
        public string GetPageText(TextResource textResource, TextFormatEnumContract format)
        {
            var fulltextServiceClient = m_communicationProvider.GetFulltextServiceClient();
            var result = fulltextServiceClient.GetTextResource(textResource.ExternalId, format);

            return(result.PageText);
        }
Exemple #12
0
        private bool OnApproved()
        {
            if (string.IsNullOrEmpty(TxtQueueName.Text))
            {
                GtkHelper.ShowMessageBox(this, TextResource.GetText("MSG_QUEUE_NAME_MISSING"));
                return(false);
            }
            var list2 = new List <string>(this.listStore.IterNChildren());
            var list  = GtkHelper.GetListStoreValues <EntryWrapper>(this.listStore, 5);

            foreach (var entry in list)
            {
                if (entry.Selected)
                {
                    list2.Add(entry.Entry.Id);
                }
            }
            if (modifyingQueue == null)
            {
                okAction.Invoke(new DownloadQueue(Guid.NewGuid().ToString(), TxtQueueName.Text)
                {
                    DownloadIds = list2
                }, true);
            }
            else
            {
                modifyingQueue.DownloadIds.AddRange(list2);
                okAction.Invoke(modifyingQueue, false);
            }
            return(true);
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("TextResourceId,Text,Language")] TextResource textResource)
        {
            if (id != textResource.TextResourceId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(textResource);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TextResourceExists(textResource.TextResourceId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(textResource));
        }
        private void DownloadSelectedItems(bool startImmediately, string?queueId)
        {
            if (string.IsNullOrEmpty(view.DownloadLocation))
            {
                ApplicationContext.Application !.ShowMessageBox(view, TextResource.GetText("MSG_CAT_FOLDER_MISSING"));
                return;
            }
            if (this.view.SelectedItemCount == 0)
            {
                ApplicationContext.Application !.ShowMessageBox(view, TextResource.GetText("BAT_SELECT_ITEMS"));
                return;
            }
            var quality = -1;

            if (view.SelectedFormat >= 0)
            {
                quality = this.videoQualities[view.SelectedFormat];
            }

            var selectedIndices = view.SelectedRows;

            foreach (var index in selectedIndices)
            {
                var entry = videoItemList[index];
                var fmt   = FindMatchingFormatByQuality(entry, quality);
                if (fmt.HasValue)
                {
                    AddDownload(fmt.Value, startImmediately, queueId);
                }
            }
            view.CloseWindow();
        }
        public async Task <ActionResult> Delete(string org, string app, string language)
        {
            try
            {
                TextResource existingResource = await _textRepository.Get(org, app, language);

                if (existingResource == null)
                {
                    return(NotFound());
                }

                bool deleted = await _textRepository.Delete(org, app, language);

                if (deleted)
                {
                    return(Ok());
                }
                else
                {
                    _logger.LogError($"Unable to delete text resource for {org}/{app}");
                    return(StatusCode(500, $"Unable to delete text resource for {org}/{app}"));
                }
            }
            catch (Exception e)
            {
                _logger.LogError($"Unable to delete text resource for {org}/{app}: {e.Message}");
                return(StatusCode(500, $"Unable to delete text resource for {org}/{app}"));
            }
        }
        /// <inheritdoc/>
        public async Task <List <TextResource> > Get(List <string> appIds, string language)
        {
            List <TextResource> result = new List <TextResource>();

            foreach (string appId in appIds)
            {
                string org = appId.Split("/")[0];
                string app = appId.Split("/")[1];

                // Swallowing exceptions, only adding valid text resources as this is used by messagebox
                try
                {
                    TextResource resource = await Get(org, app, language);

                    if (resource != null)
                    {
                        result.Add(resource);
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError($"Error occured when retrieving text resources for {org}-{app} in language {language}. Exception: {e}");
                }
            }

            return(result);
        }
Exemple #17
0
        public static void AttachToSystemTray()
        {
            var ctx = new ContextMenu();

            var menuExit = new MenuItem
            {
                Text = TextResource.GetText("MENU_EXIT")
            };

            menuExit.Click += (_, _) => Environment.Exit(0);

            var menuRestore = new MenuItem
            {
                Text = TextResource.GetText("MSG_RESTORE")
            };

            menuRestore.Click += (sender, e) => TrayClick?.Invoke(sender, e);

            ctx.MenuItems.Add(menuRestore);
            ctx.MenuItems.Add(menuExit);

            notifyIcon = new NotifyIcon
            {
                Text        = "XDM",
                Visible     = true,
                Icon        = new Icon(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "xdm-logo.ico")),
                ContextMenu = ctx
            };
            notifyIcon.MouseClick += NotifyIcon_MouseClick;
        }
Exemple #18
0
        private CategoryEditDialog(Builder builder, Window parent, WindowGroup group) : base(builder.GetRawOwnedObject("dialog"))
        {
            builder.Autoconnect(this);

            Modal = true;
            SetPosition(WindowPosition.CenterAlways);
            TransientFor = parent;
            this.group   = group;
            this.group.AddWindow(this);

            GtkHelper.AttachSafeDispose(this);

            Label1.Text = TextResource.GetText("SORT_NAME");
            Label2.Text = TextResource.GetText("SETTINGS_CAT_TYPES");
            Label3.Text = TextResource.GetText("SETTINGS_CAT_FOLDER");

            BtnOk.Clicked     += BtnOk_Clicked;
            BtnCancel.Clicked += BtnCancel_Clicked;
            Browse.Clicked    += Browse_Clicked;

            BtnOk.Label     = TextResource.GetText("MSG_OK");
            BtnCancel.Label = TextResource.GetText("ND_CANCEL");

            Title = TextResource.GetText("MSG_CATEGORY");
            SetDefaultSize(400, 200);
        }
Exemple #19
0
        private bool OnApproved()
        {
            if (string.IsNullOrEmpty(TxtQueueName.Text))
            {
                MessageBox.Show(this, TextResource.GetText("MSG_QUEUE_NAME_MISSING"));
                return(false);
            }
            var list2 = new List <string>(this.list.Count);

            foreach (var entry in list)
            {
                if (entry.IsSelected)
                {
                    list2.Add(entry.Id);
                }
            }
            if (modifyingQueue == null)
            {
                okAction.Invoke(new DownloadQueue(Guid.NewGuid().ToString(), TxtQueueName.Text)
                {
                    DownloadIds = list2
                }, true);
            }
            else
            {
                modifyingQueue.DownloadIds.AddRange(list2);
                okAction.Invoke(modifyingQueue, false);
            }
            return(true);
        }
Exemple #20
0
        private void LoadTexts()
        {
            BtnNew.Label    = TextResource.GetText("DESC_NEW");
            BtnDel.Label    = TextResource.GetText("DESC_DEL");
            BtnStart.Label  = TextResource.GetText("MENU_START_Q");
            BtnStop.Label   = TextResource.GetText("MENU_PAUSE");
            BtnSave.Label   = TextResource.GetText("DESC_SAVE_Q");
            BtnCancel.Label = TextResource.GetText("ND_CANCEL");
            BtnAdd.Label    = TextResource.GetText("Q_ADD");
            BtnRemove.Label = TextResource.GetText("Q_REMOVE");
            BtnUp.Label     = TextResource.GetText("Q_MOVE_UP");
            BtnDown.Label   = TextResource.GetText("Q_MOVE_DN");
            BtnMoveTo.Label = TextResource.GetText("Q_MOVE_TO");

            TabHeader1.Text = TextResource.GetText("Q_LIST_FILES");
            TabHeader2.Text = TextResource.GetText("Q_SCHEDULE_TXT");

            ChkEnableScheduler.Label = TextResource.GetText("Q_ENABLE");
            chkEveryday.Label        = TextResource.GetText("MSG_Q_DAILY");
            chkSun.Label             = TextResource.GetText("MSG_Q_D1");
            chkMon.Label             = TextResource.GetText("MSG_Q_D2");
            chkTue.Label             = TextResource.GetText("MSG_Q_D3");
            chkWed.Label             = TextResource.GetText("MSG_Q_D4");
            chkThu.Label             = TextResource.GetText("MSG_Q_D5");
            chkFri.Label             = TextResource.GetText("MSG_Q_D6");
            chkSat.Label             = TextResource.GetText("MSG_Q_D7");
            LblQueueStart.Text       = TextResource.GetText("MSG_Q_START");
            LblQueueStop.Text        = TextResource.GetText("MSG_Q_STOP");
        }
Exemple #21
0
    private void Awake()
    {
        _networkManager = NetworkManager.GetInstance();
        _setting        = Setting.GetInstance();
        _textResource   = TextResource.GetInstance();

        IsShowSignIn = true;

        // 자동 로그인이 설정된 경우
        if (_setting.IsEnabledAutoLogin)
        {
            TglEnabledAutoLogin.isOn = true;

            Email    = _setting.Email;
            Password = _setting.Password;

            OnClickBtnSignIn();
        }

        BtnSignIn.onClick.AddListener(OnClickBtnSignIn);
        BtnSignUp.onClick.AddListener(OnClickBtnSignUp);
        BtnFacebookSignIn.onClick.AddListener(OnClickBtnFacebookSignIn);
        BtnFacebookSignUp.onClick.AddListener(OnClickBtnFacebookSignUp);
        BtnShowSignIn.onClick.AddListener(OnClickBtnShowSignIn);
        BtnShowSignUp.onClick.AddListener(OnClickBtnShowSignUp);
        BtnBack.onClick.AddListener(OnClickBtnBack);
        TglEnabledAutoLogin.onValueChanged.AddListener(OnChangedTglEnabledAutoLogin);

        SetTextSize();
        SetTextValue();
    }
Exemple #22
0
        /// <inheritdoc />
        public async Task <TextResource> GetText(string org, string app, string language)
        {
            TextResource textResource = null;
            string       cacheKey     = $"{org}-{app}-{language.ToLower()}";

            if (!_memoryCache.TryGetValue(cacheKey, out textResource))
            {
                // Key not in cache, so get text from Platform Storage
                string url   = $"applications/{org}/{app}/texts/{language}";
                string token = JwtTokenUtil.GetTokenFromContext(_httpContextAccessor.HttpContext, _settings.RuntimeCookieName);

                HttpResponseMessage response = await _client.GetAsync(token, url);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    textResource = await response.Content.ReadAsAsync <TextResource>();

                    _memoryCache.Set(cacheKey, textResource, cacheEntryOptions);
                }
                else
                {
                    _logger.LogError($"Getting text resource for {org}/{app} with language code: {language} failed with statuscode {response.StatusCode}");
                }
            }

            return(textResource);
        }
Exemple #23
0
        async public Task TestTextMessage()
        {
            var scotchMode = ScotchMode.Replaying;
            var client     = HttpClients.NewHttpClient("IntegrationTests/Cassettes/TextMessage.json", scotchMode);

            string tokenKey    = "key";
            string tokenSecret = "secret";
            string host        = "https://dvfoa3pu2rxx6.cloudfront.net/api/v1/";

            OmnigageClient.Init(tokenKey, tokenSecret, host, client);

            TextMessageResource textMessage = new TextMessageResource();

            textMessage.Body = "Sample body";

            await textMessage.Create();

            TextResource text = new TextResource();

            text.To          = "+14076413749";
            text.TextMessage = textMessage;
            text.PhoneNumber = new PhoneNumberResource
            {
                Id = "GncieHvbCKfMYXmeycoWZm"
            };

            await text.Create();
        }
Exemple #24
0
 public string Get(TextResource resource)
 {
     if (!_dictionarySelected)
     {
         SelectDictionary(_language);
     }
     return(_currentDictionary[resource]);
 }
Exemple #25
0
 private void LoadTexts()
 {
     LblQueueName.Text      = TextResource.GetText("MSG_QUEUE_NAME");
     LblQueueSelection.Text = TextResource.GetText("MSG_QUEUE_SELECT_ITEMS");
     ChkSelectAll.Label     = TextResource.GetText("VID_CHK");
     BtnOK.Label            = TextResource.GetText("MSG_OK");
     BtnCancel.Label        = TextResource.GetText("ND_CANCEL");
 }
Exemple #26
0
        public string GetPageTextFromSearch(TextResource textResource, TextFormatEnumContract format,
                                            SearchPageRequestContract searchRequest)
        {
            var fulltextServiceClient = m_communicationProvider.GetFulltextServiceClient();
            var result = fulltextServiceClient.GetTextResourceFromSearch(textResource.ExternalId, format, searchRequest);

            return(result.PageText);
        }
Exemple #27
0
        public Task <TextResource> Create(string org, string app, TextResource textResource)
        {
            string language = textResource.Language;

            ValidateArguments(org, app, language);
            PreProcess(org, app, language, textResource);

            return(Task.FromResult(textResource));
        }
        public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            TextResource textResource = await _db.TextResources.FindAsync(id);

            _db.TextResources.Remove(textResource);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemple #29
0
        async Task ShowException(ulong exceptionId, [CallFlag('f', "full", Flags.EXCEPTION_F)] bool full = false)
        {
            var exception = await Database.FindById <Error>(exceptionId);

            if (exception == null)
            {
                await ReplyAsync(ExceptionText.NOTFOUND, ReplyType.Error, exceptionId);

                return;
            }

            var user    = Client.GetUser(exception.User ?? 0);
            var channel = Client.GetChannel(exception.Channel ?? 0) as IMessageChannel;
            var message = channel?.GetMessageAsync(exception.Message ?? 0)?.Result as IUserMessage;

            if (full)
            {
                var text = TextResource.GetResource(ExceptionText.USER) + $":\n{(user?.Username ?? TBLocalisation.UNKNOWNUSER)}#{user?.Discriminator ?? "0000"} ({user?.Id})\n" +
                           TextResource.GetResource(ExceptionText.CHANNEL) + $":\n{channel.Name} ({channel.Id})\n";
                if (channel is IGuildChannel guildChannel)
                {
                    text += $"{TextResource.GetResource(ExceptionText.GUILD)}:\n{guildChannel.Guild.Name} ({guildChannel.Guild.Id})\n";
                }
                text += $"{TextResource.GetResource(ExceptionText.MESSAGE)}:\n{message.Content}\n\n";
                text += exception.Content;

                await Reply().WithAttachment(() => text.ToStream(), $"Exception{exceptionId}.txt")
                .WithMessage(new LocalisedString(ExceptionText.FULLMESSAGE, ReplyType.Success, exceptionId))
                .SendAsync();
            }
            else
            {
                var builder = new LocalisedEmbedBuilder
                {
                    Timestamp = exception.Time,
                    Color     = Color.Red
                }.WithRawDescription(exception.Description)
                .AddField(f => f.WithName(ExceptionText.MESSAGE).WithRawValue(message.Content))
                .AddInlineField(f => f.WithName(ExceptionText.CHANNEL).WithRawValue($"{channel.Name} ({channel.Id})"));

                if (user == null)
                {
                    builder.WithAuthor(a => a.WithName(TBLocalisation.UNKNOWNUSER));
                }
                else
                {
                    builder.WithAuthor(a => a.WithIconUrl(user.GetAvatarUrl()).WithRawName($"{user.Username}#{user.Discriminator}"));
                }

                if (channel is IGuildChannel guildChannel)
                {
                    builder.AddInlineField(f => f.WithName(ExceptionText.GUILD).WithRawValue($"{guildChannel.Guild.Name} ({guildChannel.Guild.Id})"));
                }

                await ReplyAsync(builder);
            }
        }
Exemple #30
0
 public void DownloadFailed(object?sender, DownloadFailedEventArgs e)
 {
     active = false;
     Dispatcher.Invoke(new Action(() =>
     {
         MessageBox.Show(this, TextResource.GetText("MSG_FAILED"));
         Close();
     }));
 }
Exemple #31
0
 public static int Insert(Zippy.Data.IDalProvider db, TextResource entity)
 {
     int rtn = db.Insert(entity);
     return rtn;
 }
Exemple #32
0
 public static int Update(Zippy.Data.IDalProvider db, TextResource entity)
 {
     return db.Update(entity);
 }
Exemple #33
0
        private bool GetYesNo(string text)
        {
            var retVal = false;
            var quitPanel = false;
            byte mouseType = Logic.MOUSE_NORMAL;
            byte wantMouse = Logic.MOUSE_NORMAL;
            ushort textY = MpnlY;
            byte[] dlgTextDat;

            _yesNo.DrawToScreen(WithMask);
            if (text != null)
            {
                var dlgLtm = _skyText.DisplayText(text, null, true,
                    (ushort)(ServiceLocator.Platform.ToStructure<DataFileHeader>(_yesNo.SpriteData, 0).s_width - 8), 37);
                dlgTextDat = dlgLtm.TextData;
                textY =
                    (ushort)
                        (MpnlY + 44 +
                         (28 - ServiceLocator.Platform.ToStructure<DataFileHeader>(dlgTextDat, 0).s_height) / 2);
            }
            else
                dlgTextDat = null;

            var dlgText = new TextResource(dlgTextDat, 1, 0, MpnlX + 2, textY, 0, DoNothing, _system, _screenBuf);
            dlgText.DrawToScreen(WithMask);

            while (!quitPanel)
            {
                if (mouseType != wantMouse)
                {
                    mouseType = wantMouse;
                    _skyMouse.SpriteMouse(mouseType, 0, 0);
                }
                _system.GraphicsManager.UpdateScreen();
                Delay(50);
                if (_controlPanel == null)
                {
                    return false;
                }
                var mouse = _system.InputManager.GetMousePosition();
                if ((mouse.Y >= 83) && (mouse.Y <= 110))
                {
                    if ((mouse.X >= 77) && (mouse.X <= 114))
                    {
                        // over 'yes'
                        wantMouse = Logic.MOUSE_CROSS;
                        if (_mouseClicked)
                        {
                            quitPanel = true;
                            retVal = true;
                        }
                    }
                    else if ((mouse.X >= 156) && (mouse.X <= 193))
                    {
                        // over 'no'
                        wantMouse = Logic.MOUSE_CROSS;
                        if (_mouseClicked)
                        {
                            quitPanel = true;
                        }
                    }
                    else
                        wantMouse = Logic.MOUSE_NORMAL;
                }
                else
                    wantMouse = Logic.MOUSE_NORMAL;
            }
            _mouseClicked = false;
            _skyMouse.SpriteMouse(Logic.MOUSE_NORMAL, 0, 0);
            return retVal;
        }
Exemple #34
0
 public ControlStatus(Text skyText, ISystem system, byte[] scrBuf)
 {
     _skyText = skyText;
     _system = system;
     _screenBuf = scrBuf;
     _textData = null;
     _statusText = new TextResource(null, 2, 1, 64, 163, 0, DoNothing, _system, _screenBuf);
 }
Exemple #35
0
 private void RemovePanel()
 {
     _screenBuf = null;
     _sprites.ControlPanel = null;
     _sprites.Button = null;
     _sprites.ButtonDown = null;
     _sprites.SavePanel = null;
     _sprites.YesNo = null;
     _sprites.Slide = null;
     _sprites.Slide2 = null;
     _sprites.Slode = null;
     _sprites.Slode2 = null;
     _sprites.MusicBodge = null;
     _controlPanel = null;
     _exitButton = null;
     _controlPanel = null;
     _slide = null;
     _slide2 = null;
     _slode = null;
     _restorePanButton = null;
     _savePanel = null;
     _saveButton = null;
     _downFastButton = null;
     _downSlowButton = null;
     _upFastButton = null;
     _upSlowButton = null;
     _quitButton = null;
     _autoSaveButton = null;
     _savePanButton = null;
     _dosPanButton = null;
     _restartPanButton = null;
     _fxPanButton = null;
     _musicPanButton = null;
     _bodge = null;
     _yesNo = null;
     _text = null;
     _statusBar = null;
     _restoreButton = null;
     _textSprite = null;
 }
Exemple #36
0
        private void InitPanel()
        {
            _screenBuf = new byte[Screen.GameScreenWidth * Screen.FullScreenHeight];

            var volY = (ushort)((127 - _skyMusic.Volume) / 4 + 59 - MpnlY); // volume slider's Y coordinate
            var spdY = (ushort)((SystemVars.Instance.GameSpeed - 2) / SpeedMultiply);
            spdY += MpnlY + 83; // speed slider's initial position

            _sprites.ControlPanel = _skyDisk.LoadFile(60500);
            _sprites.Button = _skyDisk.LoadFile(60501);
            _sprites.ButtonDown = _skyDisk.LoadFile(60502);
            _sprites.SavePanel = _skyDisk.LoadFile(60503);
            _sprites.YesNo = _skyDisk.LoadFile(60504);
            _sprites.Slide = _skyDisk.LoadFile(60505);
            _sprites.Slode = _skyDisk.LoadFile(60506);
            _sprites.Slode2 = _skyDisk.LoadFile(60507);
            _sprites.Slide2 = _skyDisk.LoadFile(60508);
            if (SystemVars.Instance.GameVersion.Version.Minor < 368)
                _sprites.MusicBodge = null;
            else
                _sprites.MusicBodge = _skyDisk.LoadFile(60509);

            //Main control panel:                                            X    Y Text       OnClick
            _controlPanel = CreateResource(_sprites.ControlPanel, 1, 0, 0, 0, 0, DoNothing, Mainpanel);
            _exitButton = CreateResource(_sprites.Button, 3, 0, 16, 125, 50, Exit, Mainpanel);
            _slide = CreateResource(_sprites.Slide2, 1, 0, 19, (short)spdY, 95, SpeedSlide, Mainpanel);
            _slide2 = CreateResource(_sprites.Slide2, 1, 0, 19, (short)volY, 14, MusicSlide, Mainpanel);
            _slode = CreateResource(_sprites.Slode2, 1, 0, 9, 49, 0, DoNothing, Mainpanel);
            _restorePanButton = CreateResource(_sprites.Button, 3, 0, 58, 19, 51, RestGamePanel, Mainpanel);
            _savePanButton = CreateResource(_sprites.Button, 3, 0, 58, 39, 48, SaveGamePanel, Mainpanel);
            _dosPanButton = CreateResource(_sprites.Button, 3, 0, 58, 59, 93, QuitToDos, Mainpanel);
            _restartPanButton = CreateResource(_sprites.Button, 3, 0, 58, 79, 94, Restart, Mainpanel);
            _fxPanButton = CreateResource(_sprites.Button, 3, 0, 58, 99, 90, ToggleFx, Mainpanel);

            if (SkyEngine.IsCDVersion)
            {
                // CD Version: Toggle text/speech
                _musicPanButton = CreateResource(_sprites.Button, 3, 0, 58, 119, 52, ToggleText, Mainpanel);
            }
            else
            {
                // disk version: toggle music on/off
                _musicPanButton = CreateResource(_sprites.Button, 3, 0, 58, 119, 91, ToggleMs, Mainpanel);
            }
            _bodge = CreateResource(_sprites.MusicBodge, 2, 1, 98, 115, 0, DoNothing, Mainpanel);
            _yesNo = CreateResource(_sprites.YesNo, 1, 0, -2, 40, 0, DoNothing, Mainpanel);

            _text = new TextResource(null, 1, 0, 15, 137, 0, DoNothing, _system, _screenBuf);
            _controlPanLookList = new[]
            {
                _exitButton,
                _restorePanButton,
                _savePanButton,
                _dosPanButton,
                _restartPanButton,
                _fxPanButton,
                _musicPanButton,
                _slide,
                _slide2
            };


            // save/restore panel
            _savePanel = CreateResource(_sprites.SavePanel, 1, 0, 0, 0, 0, DoNothing, Savepanel);
            _saveButton = CreateResource(_sprites.Button, 3, 0, 29, 129, 48, SaveAGame, Savepanel);
            _downFastButton = CreateResource(_sprites.ButtonDown, 1, 0, 212, 114, 0, ShiftDownFast, Savepanel);
            _downSlowButton = CreateResource(_sprites.ButtonDown, 1, 0, 212, 104, 0, ShiftDownSlow, Savepanel);
            _upFastButton = CreateResource(_sprites.ButtonDown, 1, 0, 212, 10, 0, ShiftUpFast, Savepanel);
            _upSlowButton = CreateResource(_sprites.ButtonDown, 1, 0, 212, 21, 0, ShiftUpSlow, Savepanel);
            _quitButton = CreateResource(_sprites.Button, 3, 0, 72, 129, 49, SpCancel, Savepanel);
            _restoreButton = CreateResource(_sprites.Button, 3, 0, 29, 129, 51, RestoreAGame, Savepanel);
            _autoSaveButton = CreateResource(_sprites.Button, 3, 0, 115, 129, 0x8FFF, RestoreAuto, Savepanel);

            _savePanLookList = new[]
            {
                _saveButton,
                _downSlowButton,
                _downFastButton,
                _upFastButton,
                _upSlowButton,
                _quitButton
            };
            _restorePanLookList = new[]
            {
                _restoreButton,
                _downSlowButton,
                _downFastButton,
                _upFastButton,
                _upSlowButton,
                _quitButton,
                _autoSaveButton
            };

            _statusBar = new ControlStatus(_skyText, _system, _screenBuf);

            _textSprite = null;
        }