public SourceSplitComponent(LiveSplitState state, bool isLayoutComponent) { // make Debug.WriteLine prepend update count and tick count while (Debug.Listeners.Count > 0) { Debug.Listeners.RemoveAt(0); } Debug.Listeners.Add(TimedTraceListener.Instance); while (Trace.Listeners.Count > 0) { Trace.Listeners.RemoveAt(0); } Trace.Listeners.Add(TimedTraceListener.Instance); // is it okay to use the same instance? //Debug.AutoFlush = Trace.AutoFlush = true; _state = state; this.IsLayoutComponent = isLayoutComponent; this.Settings = new SourceSplitSettings(); this.InternalComponent = new InfoTimeComponent("Game Time", null, new RegularTimeFormatter(TimeAccuracy.Hundredths)); this.ContextMenuControls = new Dictionary <String, Action>(); this.ContextMenuControls.Add("SourceSplit: Map Times", () => MapTimesForm.Instance.Show()); _cache = new GraphicsCache(); _timer = new TimerModel { CurrentState = state }; state.OnSplit += state_OnSplit; state.OnReset += state_OnReset; state.OnStart += state_OnStart; _mapsVisited = new List <string>(); _gameMemory = new GameMemory(this.Settings); _gameMemory.OnSessionTimeUpdate += gameMemory_OnSessionTimeUpdate; _gameMemory.OnPlayerGainedControl += gameMemory_OnPlayerGainedControl; _gameMemory.OnPlayerLostControl += gameMemory_OnPlayerLostControl; _gameMemory.OnMapChanged += gameMemory_OnMapChanged; _gameMemory.OnSessionStarted += gameMemory_OnSessionStarted; _gameMemory.OnSessionEnded += gameMemory_OnSessionEnded; _gameMemory.OnNewGameStarted += gameMemory_OnNewGameStarted; _gameMemory.StartReading(); }
public TimerViewModel(TimerModel model) { model.StateObservable().Subscribe((TimerState state) => { if (state == TimerState.FINISHED) { Messenger.Raise(new WindowActionMessage(WindowAction.Close, "Close")); } }); model.TimeObservable().Subscribe((int time) => { int h = time / (60 * 60); time -= h * (60 * 60); int m = time / 60; time -= m * 60; int s = time; Text = String.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s); }); model.Start(); }
public CommandServer(LiveSplitState state) { Model = new TimerModel(); Connections = new List <Connection>(); DeltaFormatter = new DeltaTimeFormatter() { Accuracy = TimeAccuracy.Hundredths, DropDecimals = false }; SplitTimeFormatter = new RegularTimeFormatter(TimeAccuracy.Hundredths); State = state; Form = state.Form; Model.CurrentState = State; State.OnStart += State_OnStart; }
public ElMatadorComponent(LiveSplitState state, bool isLayoutComponent) { _state = state; this.IsLayoutComponent = isLayoutComponent; this.Settings = new ElMatadorSettings(); _timer = new TimerModel { CurrentState = state }; _timer.CurrentState.OnStart += timer_OnStart; _gameMemory = new GameMemory(this.Settings); _gameMemory.OnLoadStarted += gameMemory_OnLoadStarted; _gameMemory.OnLoadFinished += gameMemory_OnLoadFinished; state.OnStart += State_OnStart; _gameMemory.StartMonitoring(); }
public void save() { List <TimerModel> lstTimer = md.lstTimer; for (int i = 0; i < lstTimer.Count; ++i) { TimerModel tm = lstTimer[i]; lstTimer[i].time = TimeFormat.formatTime(tm.hour, tm.minute, tm.second); } List <ClockModel> lstClock = md.lstClock; for (int i = 0; i < lstClock.Count; ++i) { ClockModel cm = lstClock[i]; lstClock[i].time = TimeFormat.formatTime(cm.hour, cm.minute); } }
public ShareRunDialog(LiveSplitState state, ISettings settings, Func <Image> screenShotFunction) { State = state; if (State.CurrentPhase != TimerPhase.Ended) { Run = state.Run; } else { var model = new TimerModel(); model.CurrentState = State; model.SetRunAsPB(); Run = State.Run; } ScreenShotFunction = screenShotFunction; Settings = settings; InitializeComponent(); }
public bool split(Process dsProcess, TimerModel timer, PlayerPos playerPos, out bool loadSplitQueued, out bool finalSplitFlag) { loadSplitQueued = false; finalSplitFlag = false; if (_enabled && _settingsNode.Checked) { _maxUpgradeLevel.Update(dsProcess); if (_maxUpgradeLevel.Current == _upgradeLevel) { Trace.WriteLine("UpgradeSplit queued: +" + _upgradeLevel); loadSplitQueued = true; _enabled = false; return(true); } return(false); } return(false); }
public OoSComponent(LiveSplitState state) { settings = new OoSSettings(); model = new TimerModel() { CurrentState = state }; model.CurrentState.OnStart += timer_OnStart; processTimer = new Timer() { Interval = 2000, Enabled = true }; processTimer.Tick += processTimer_OnTick; memory = new OoSMemory(); }
public ServerComponent(LiveSplitState state) { Settings = new Settings(); Model = new TimerModel(); Connections = new List <Connection>(); DeltaFormatter = new PreciseDeltaFormatter(TimeAccuracy.Hundredths); SplitTimeFormatter = new RegularTimeFormatter(TimeAccuracy.Hundredths); ContextMenuControls = new Dictionary <string, Action>(); ContextMenuControls.Add("Start Server", Start); State = state; Form = state.Form; Model.CurrentState = State; State.OnStart += State_OnStart; }
public TimerControl(Lazy<InSourceViewControl> control) { InitializeComponent(); _timerSettings = _persistence.LoadTimerSettings(); _timer = new Timer(); _timer.Elapsed += _timer_Elapsed; _timer.Interval = 60000; _timer.AutoReset = true; _timer.Start(); _control = control; if (_timerSettings.HasTimer) { timerCheckBox.Checked = true; timeTextBox.Enabled = true; timeLbl.ForeColor = Color.Black; timeTextBox.Text = _timerSettings.Minutes.ToString(); _timeLeft = _timerSettings.Minutes; _timer.Enabled = true; _timer.Elapsed += _timer_Elapsed; remainingTimeLbl.Text = _timerSettings.Minutes.ToString(); } else { timerCheckBox.Checked = false; timeTextBox.Enabled = false; timeLbl.ForeColor = Color.Gray; timeTextBox.Text = @"0"; remainingTimeLbl.Text = @"Timer is disabled"; remainingTimeLbl.ForeColor = Color.Gray; timerLbl.ForeColor = Color.Gray; _timer.Stop(); } timeTextBox.TextChanged += TimeTextBox_TextChanged; }
public void load() { List <TimerModel> lstTimer = md.lstTimer; for (int i = 0; i < lstTimer.Count; ++i) { TimerModel tm = lstTimer[i]; TimeFormat.parseTime(lstTimer[i].time, out tm.hour, out tm.minute, out tm.second); //lstTimer[i].totalSecond = hour * 3600 + minute * 60 + second; } List <ClockModel> lstClock = md.lstClock; for (int i = 0; i < lstClock.Count; ++i) { ClockModel cm = lstClock[i]; TimeFormat.parseTime(lstClock[i].time, out cm.hour, out cm.minute); } }
public void Update(IInvalidator invalidator, LiveSplitState lvstate, float width, float height, LayoutMode mode) { if (Model == null) { Model = new TimerModel() { CurrentState = lvstate }; lvstate.OnReset += OnReset; lvstate.OnPause += OnPause; lvstate.OnResume += OnResume; lvstate.OnStart += OnStart; lvstate.OnSplit += OnSplit; lvstate.OnUndoSplit += OnUndoSplit; lvstate.OnSkipSplit += OnSkipSplit; } GetValues(invalidator, lvstate, width, height, mode); }
private void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); //Setup _starttime = new DateTime(2018, 09, 22, 12, 24, 0); Timer = new TimerModel(_starttime); _importer = new Importer(_appListObject.GetList()); }
public Shrek2Component(LiveSplitState lss) { LSS = lss; Settings = new Shrek2Settings(lss); Timer = new TimerModel { CurrentState = lss }; AutoSplitter = new Shrek2AutoSplitter(); AutoSplitter.OnMainMenuLoad = OnMainMenuLoad; AutoSplitter.OnNewGame = OnNewGame; AutoSplitter.OnSplit = OnSplit; AutoSplitter.OnPause = OnPause; AutoSplitter.OnResume = OnResume; LSS.OnStart += OnStart; AutoSplitter.Start(); }
public RecordingViewModel(RecordingModel recordingModel, Settings settings, TimerModel timerModel, VideoSourcesViewModel videoSourcesViewModel) { _recordingModel = recordingModel; RecordCommand = new[] { settings.Audio .ObserveProperty(audioSettings => audioSettings.Enabled), videoSourcesViewModel .ObserveProperty(sourcesViewModel => sourcesViewModel.SelectedVideoSourceKind) .Select(videoSourceProvider => !(videoSourceProvider is NoVideoSourceProvider)) } .CombineLatest(bools => bools[0] || bools[1]) .ToReactiveCommand() .WithSubscribe(recordingModel.OnRecordExecute); PauseCommand = new[] { timerModel .ObserveProperty(model => model.Waiting), recordingModel .ObserveProperty(model => model.RecorderState) .Select(recorderState => recorderState != RecorderState.NotRecording) } .CombineLatest(bools => !bools[0] && bools[1]) .ToReactiveCommand() .WithSubscribe(recordingModel.OnPauseExecute); recordingModel.PropertyChanged += (sender, e) => { switch (e.PropertyName) { case "": case null: case nameof(RecorderState): RaisePropertyChanged(nameof(RecorderState)); break; } }; }
/// <summary> /// Updates the component. This is where most of the actual autosplitting work is done. /// </summary> public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { if (timer == null) { timer = new TimerModel { CurrentState = state }; state.OnSplit += OnSplit; state.OnUndoSplit += OnUndoSplit; state.OnSkipSplit += OnSkipSplit; state.OnReset += OnReset; } bool processPreviouslyHooked = processHooked; Autosplit(); if (processHooked) { // If someone keeps the timer running after exiting to the menu, it's probably also useful to keep display death count for // that run until the timer is reset. deathCount = memory.CheckInGame() || timer.CurrentState.CurrentPhase == TimerPhase.Running ? Math.Max(deathCount, memory.GetDeathCount()) : 0; } // The death count should reset to zero when the game exits. if (!processHooked && processPreviouslyHooked) { deathCount = 0; } if (processHooked || processPreviouslyHooked) { textComponent.InformationValue = deathCount.ToString(); textComponent.Update(invalidator, state, width, height, mode); invalidator?.Invalidate(0, 0, width, height); } }
public FezComponent(LiveSplitState state) { settings = new FezSettings(); timer = new TimerModel() { CurrentState = state }; timer.CurrentState.OnStart += timer_OnStart; processTimer = new Timer() { Interval = 2000, Enabled = true }; processTimer.Tick += processTimer_OnTick; memory = new FezMemory(); memory.LoadStart += memory_OnLoadStart; memory.LoadEnd += memory_OnLoadEnd; }
public SkyrimComponent(LiveSplitState state) { bool debug = false; #if DEBUG debug = true; #endif Trace.WriteLine($"[NoLoads] Using LiveSplit.Skyrim component version {Assembly.GetExecutingAssembly().GetName().Version} {(debug ? "Debug" : "Release")} build"); _state = state; try { MediaPlayer = new MediaPlayer(); } catch { MediaPlayer = null; } this.Settings = new SkyrimSettings(this, state); _timer = new TimerModel { CurrentState = state }; this.BearCartSplit = new Time(); this.BearCartDefaultSoundPath = System.IO.Path.GetTempPath() + @"LiveSplit.Skyrim\bearcart.mp3"; //extract embedded sound to temp folder try { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(BearCartDefaultSoundPath)); System.IO.File.WriteAllBytes(BearCartDefaultSoundPath, Properties.Resources.bearcart_short); } catch (System.IO.IOException) { Trace.WriteLine("[NoLoads] Error when extracting bear cart sound to temp folder."); } _gameMemory = new GameMemory(); _gameMemory.AutoSplitManager.AutoSplitList = Settings.AutoSplitList; _gameMemory.OnStartSaveLoad += gameMemory_OnStartSaveLoad; _gameMemory.OnLoadStarted += gameMemory_OnLoadStarted; _gameMemory.OnLoadFinished += gameMemory_OnLoadFinished; _gameMemory.OnBearCart += gameMemory_OnBearCart; _gameMemory.OnSplit += _gameMemory_OnSplit; state.OnStart += State_OnStart; state.OnReset += State_OnReset; _gameMemory.StartMonitoring(); }
public Quake4Component(LiveSplitState state, bool isLayoutComponent) { _state = state; this.IsLayoutComponent = isLayoutComponent; this.Settings = new Quake4Settings(); _timer = new TimerModel { CurrentState = state }; _timer.CurrentState.OnPause += timer_OnStart; _gameMemory = new GameMemory(this.Settings); _gameMemory.OnFirstLevelLoading += gameMemory_OnFirstLevelLoading; _gameMemory.OnPlayerGainedControl += gameMemory_OnPlayerGainedControl; _gameMemory.OnLoadStarted += gameMemory_OnLoadStarted; _gameMemory.OnLoadFinished += gameMemory_OnLoadFinished; _gameMemory.OnSplitCompleted += gameMemory_OnSplitCompleted; state.OnStart += State_OnStart; _gameMemory.StartMonitoring(); }
private void CreateTimerModels() { List <TimerModel> tm = new List <TimerModel>(); XmlReader r = XmlReader.Create(AppResources.SourceFile); while (r.Read()) { if (r.NodeType == XmlNodeType.Element && r.Name == "Timer") { DateTime d = DateTime.Parse(r.GetAttribute("Date"), new CultureInfo(AppResources.AppCulture)); TimerModel t = new TimerModel() { Description = r.GetAttribute("Name"), StartDate = d, }; tm.Add(t); } } Timers = tm; }
public void Update(IInvalidator invalidator, LiveSplitState lvstate, float width, float height, LayoutMode mode) { if (Model == null) { Model = new TimerModel() { CurrentState = lvstate }; Model.InitializeGameTime(); Model.CurrentState.IsGameTimePaused = true; lvstate.OnReset += OnReset; lvstate.OnPause += OnPause; lvstate.OnResume += OnResume; lvstate.OnStart += OnStart; lvstate.OnSplit += OnSplit; lvstate.OnUndoSplit += OnUndoSplit; lvstate.OnSkipSplit += OnSkipSplit; } GetValues(); }
public UnderworldAscendantComponent(LiveSplitState state, bool isLayoutComponent) { _state = state; this.IsLayoutComponent = isLayoutComponent; this.Settings = new UnderworldAscendantSettings(); _timer = new TimerModel { CurrentState = state }; _timer.CurrentState.OnStart += timer_OnStart; _gameMemory = new GameMemory(this.Settings); _gameMemory.OnFirstLevelLoad += gameMemory_OnFirstLevelLoaded; _gameMemory.OnLoadStarted += gameMemory_OnLoadStarted; _gameMemory.OnLoadFinished += gameMemory_OnLoadFinished; _gameMemory.OnLevelChanged += gameMemory_OnLevelChanged; state.OnStart += State_OnStart; _gameMemory.StartMonitoring(); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { TimerModel md = new TimerModel(); TimerVM vm = new TimerVM() { Index = lstTimerVM.Count, md = md, IsNew = true, }; foreach (var item in lstTimerVM) { item.IsNew = false; } arrTimer.Add(md); lstTimerVM.Add(vm); lstTimer.ScrollIntoView(lstTimerVM.Last()); AutoSaveServer.ins.hasChanged = true; }
// Start is called before the first frame update void Awake() { model = new TimerModel(); model.Initialize(); stateView.OnClickPlay = model.OnClickPlayButton; stateView.OnClickReset = model.OnClickResetButton; stateView.OnClickStop = model.OnClickStopButton; stateView.OnClickPause = model.OnClickPauseButton; model.timerState.Subscribe(nextState => { model.preTimerState?.Exit(); nextState?.Enter(); model.preTimerState = nextState; }); model.currentTime.Subscribe(value => { view.OnTimeChange(value, model.originalTime); foreach (var numView in numViews) { numView.OnTimeChange(value); } }); TimerModel.stateIdle.OnStateEnter.AddListener(stateView.StateIdleEnter); TimerModel.statePause.OnStateEnter.AddListener(stateView.StatePauseEnter); TimerModel.StateAlarm.OnStateEnter.AddListener(stateView.StateAlarmEnter); TimerModel.statePlaying.OnStateEnter.AddListener(stateView.StatePlayingEnter); TimerModel.statePause.OnStateExit.AddListener(stateView.StatePauseExit); TimerModel.StateAlarm.OnStateExit.AddListener(stateView.StateAlarmExit); foreach (var numView in numViews) { numView.OnAddNum = model.AddNum; TimerModel.stateIdle.OnStateEnter.AddListener(numView.OnButtonActive); TimerModel.stateIdle.OnStateExit.AddListener(numView.OnButtonDeactive); numView.Initialized(); } view.OnTimeUpdate = model.TimeUpdate; model.timerState.Value = TimerModel.stateIdle; }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { int millis = Pointer.GetIgt(); //Native.GetGameTimeMilliseconds(addr, p.Id.GetHandle(), 8); if (millis > 100) { _oldMillis = millis; _latch = false; } if (millis == 0 && !_latch) { _oldMillis -= 594; _latch = true; } if (_oldMillis <= 0) { _oldMillis = 0; } state.SetGameTime(new TimeSpan(0, 0, 0, 0, _oldMillis <= 1 ? 1 : _oldMillis)); //autostart timer. Might be worth changing this to something based on some memory flag if (_control.cb_autoStartTimer.Checked && millis > 0 && millis < 500) { if (state.CurrentPhase == TimerPhase.NotRunning) { TimerModel timer = new TimerModel(); timer.CurrentState = state; timer.Start(); } } //autosplit if (_control.cb_autoSplit.Checked) { _splitter.AttemptSplit(); } }
/// <summary> /// 达到一定时间间隔的时候进行触发的事件回调函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnTimerelapsed(object sender, ElapsedEventArgs e) { lock (this.removeTimerModelById) { TimerModel tmpModel = null; if (this.removeTimerModelById.Count > 0) { foreach (var modelId in this.removeTimerModelById) //循环遍历要移除的计时任务编号集合 { this.timerDictionary.TryRemove(modelId, out tmpModel); //进行移除 } this.removeTimerModelById.Clear(); } } if (this.timerDictionary.Count > 0) { foreach (TimerModel model in this.timerDictionary.Values) //循环遍历存储计时任务的字典 { model.Run(); //开始执行计时任务 } } }
public TwitchPredictionsComponent(LiveSplitState state, bool isLayoutComponent) { _state = state; this.IsLayoutComponent = isLayoutComponent; this.Settings = new TwitchPredictionsSettings(state); _state.RunManuallyModified += Settings._state_RunManuallyModified; _timer = new TimerModel { CurrentState = state }; _twitchConnection = TwitchConnection.GetInstance(); if (_twitchConnection._connectionData.ConnectOnLaunch) { _twitchConnection.Connect(); } //Set required timer events _timer.CurrentState.OnStart += CurrentState_OnStart; _timer.CurrentState.OnSkipSplit -= CurrentState_OnSplit; //essentially identical on split _timer.CurrentState.OnSplit += CurrentState_OnSplit; _timer.CurrentState.OnReset += CurrentState_OnReset; }
public MainWindowViewModel() { HelpModel = new HelpModel(); HelpModel.HelpDataContext(); RecvModel = new RecvModel(); RecvModel.RecvDataContext(); SendModel = new SendModel(); SendModel.SendDataContext(); SerialPortModel = new SerialPortModel(); SerialPortModel.SerialPortDataContext(); DepictInfo = "串行端口调试助手"; TimerModel = new TimerModel(); TimerModel.TimerDataContext(); AutoSend = false; InitAutoSendTimer(); }
public void process(Process dsProcess, TimerModel timer, out bool loadSplitQueued, out bool finalSplitFlag) { loadSplitQueued = false; finalSplitFlag = false; if (!initilized) { foreach (ISplit spl in splits) { spl.init(dsProcess); } initilized = true; } else { foreach (ISplit spl in splits) { if (spl.split(dsProcess, timer, _playerPos, out loadSplitQueued, out finalSplitFlag)) { break; } } } }
public BMComponent(LiveSplitState state, bool isLayoutComponent) { _state = state; this.IsLayoutComponent = isLayoutComponent; this.Settings = new BMSettings(); _timer = new TimerModel { CurrentState = state }; _timer.CurrentState.OnStart += timer_OnStart; _gameMemory = new GameMemory(this.Settings); _gameMemory.OnSplitCompleted += gameMemory_OnSplitCompleted; _gameMemory.OnFirstLevelLoaded += _gameMemory_OnFirstLevelLoaded; _gameMemory.IsLoadingChanged += _gameMemory_IsLoadingChanged; state.OnStart += State_OnStart; state.OnReset += State_OnReset; resetSplitStates(); _gameMemory.StartMonitoring(); }