public virtual void SetDisplayedCurrency(CurrencyDisplayType currency_type) { if (currency_type == _currentDisplayedCurrency || (forcedOnscreenCurrencyType != null && forcedOnscreenCurrencyType != currency_type)) { return; } _moneyDial.onPlaySound = null; drawSprite = null; _currentDisplayedCurrency = currency_type; if (currency_type != null) { _moneyDial.currentValue = _currentDisplayedCurrency.netIntDelta.Value; _moneyDial.previousTargetValue = _moneyDial.currentValue; if (currency_type.playSound != null) { _moneyDial.onPlaySound = currency_type.playSound; } else { _moneyDial.onPlaySound = DefaultPlaySound; } if (currency_type.drawSprite != null) { drawSprite = currency_type.drawSprite; } else { drawSprite = DefaultDrawSprite; } } }
public virtual void SetDisplayedCurrency(string key) { if (registeredCurrencyDisplays.ContainsKey(key)) { CurrencyDisplayType currency_type = registeredCurrencyDisplays[key]; SetDisplayedCurrency(currency_type); } }
public virtual void ShowCurrency(string currency_type) { if (currency_type == null || !registeredCurrencyDisplays.ContainsKey(currency_type)) { forcedOnscreenCurrencyType = null; return; } forcedOnscreenCurrencyType = registeredCurrencyDisplays[currency_type]; SetDisplayedCurrency(forcedOnscreenCurrencyType); }
private void UpdateCurrencyDisplayType(CurrencyDisplayType displayType) { foreach (var row in _holdingsDataGridViewRows) { row.Cells[_clmnHoldingsCoin.Index].Value = FormatCurrencyForDisplay((int)row.Tag, displayType); } foreach (var row in _marketDataGridViewRows) { row.Cells[_clmnMarketCoin.Index].Value = FormatCurrencyForDisplay((int)row.Tag, displayType); } }
public virtual void Register(string key, NetIntDelta net_int_delta, Action <int> sound_function = null, Action <SpriteBatch, Vector2> draw_function = null) { if (registeredCurrencyDisplays.ContainsKey(key)) { Unregister(key); } CurrencyDisplayType currency_type = new CurrencyDisplayType(); currency_type.key = key; currency_type.netIntDelta = net_int_delta; currency_type.playSound = sound_function; currency_type.drawSprite = draw_function; registeredCurrencyDisplays[key] = currency_type; registeredCurrencyDisplays[key].netIntDelta.fieldChangeVisibleEvent += OnCurrencyChange; }
private String FormatCurrencyForDisplay(int currencyId, CurrencyDisplayType displayType) { var currency = CurrencyTypeRegistry.GetNameAndSymbolFromId(currencyId); switch (displayType) { case CurrencyDisplayType.Name: return(currency.Item2); case CurrencyDisplayType.NameAndSymbol: return($"{currency.Item2} ({currency.Item1})"); case CurrencyDisplayType.Symbol: return(currency.Item1); case CurrencyDisplayType.SymbolAndName: return($"{currency.Item1} ({currency.Item2})"); } return(String.Empty); }