Skip to content

Commit

Permalink
V1.2.2 支持自定义启动项;日志处光标位置自动调整至末尾
Browse files Browse the repository at this point in the history
  • Loading branch information
hualuoo committed Jan 31, 2024
1 parent 3e85220 commit 54e9c61
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 23 deletions.
22 changes: 20 additions & 2 deletions activity/main_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from datetime import datetime, timedelta

from PyQt5.uic import loadUi
from PyQt5.QtGui import QIcon, QTextCharFormat, QColor
from PyQt5.QtGui import QIcon, QTextCharFormat, QColor, QTextCursor
from PyQt5.QtCore import QTimer, Qt
from PyQt5.QtWidgets import QMainWindow, QMessageBox, QFileDialog, QTableWidgetItem, QMenu, QAction, QInputDialog, QStatusBar
import psutil
Expand Down Expand Up @@ -99,6 +99,13 @@ def initUi(self):
self.config.pop("backup_dir_path")
self.save_config_json()

if "launch_options_info" in self.config:
self.line_edit_launch_options.setText(self.config["launch_options_info"])
if "launch_options_flag" in self.config:
self.check_box_launch_options.setChecked(self.config["launch_options_flag"])
self.check_box_launch_options.setEnabled(not self.config["launch_options_flag"])
self.line_edit_launch_options.setEnabled(not self.config["launch_options_flag"])

self.timed_detection_timer_1000 = QTimer(self)
self.timed_detection_timer_1000.timeout.connect(self.timed_detection_1000)
self.timed_detection_timer_1000.start(1000)
Expand Down Expand Up @@ -191,6 +198,7 @@ def timed_detection_5000(self):

def timed_detection_timer_60000(self):
if self.rcon_connect_flag is False:
self.label_online_player.setText("未连接 RCON")
return

self.table_widget_player_list.clearContents()
Expand Down Expand Up @@ -278,6 +286,9 @@ def copy_steamid(self):
pyperclip.copy(player_steamid)

def text_browser_rcon_server_notice(self, message_type, message):
cursor = self.text_browser_rcon_server.textCursor()
cursor.movePosition(QTextCursor.End)
self.text_browser_rcon_server.setTextCursor(cursor)
black_format = QTextCharFormat()
black_format.setForeground(QColor("black"))
red_format = QTextCharFormat()
Expand Down Expand Up @@ -453,6 +464,9 @@ def button_test_connect_click(self):
self.rcon_connect_flag = True
self.text_browser_rcon_server_notice("client_success", "RCON 服务器连接成功")

def check_box_launch_options_click(self, flag):
self.line_edit_launch_options.setEnabled(not flag)

def button_game_start_click(self):
if "palserver_path" not in self.config:
self.text_browser_rcon_server_notice("client_error", "请先选择PalServer.exe服务端文件!")
Expand Down Expand Up @@ -480,7 +494,11 @@ def button_game_start_click(self):
self.text_browser_rcon_server_notice("client_error", "游戏 人数上限需在2~128范围,请重新输入!")
return

command = self.config["palserver_path"] + " -port=" + game_port + " -players=" + game_player_limit + " -publicip 0.0.0.0 -publicport " + game_publicport + " -EpicAPP=PalServer"
self.config["launch_options_flag"] = self.check_box_launch_options.isChecked()
self.config["launch_options_info"] = self.line_edit_launch_options.text()
command = self.config["palserver_path"] + " -port=" + game_port + " -players=" + game_player_limit + " -publicip 0.0.0.0 -publicport " + game_publicport
if self.config["launch_options_flag"]:
command += " " + self.config["launch_options_info"]
process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
self.config["game_port"] = int(game_port)
self.config["game_publicport"] = int(game_publicport)
Expand Down
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"auto_restart_time_limit": 7200, # 自动重启时间间隔(秒)
"auto_restart_player_flag": False, # 自动重启是否判断玩家数
"auto_restart_player_limit": 0, # 仅在玩家数小于该值时自动重启
"launch_options_flag": False, # 是否开启自定义启动项
"launch_options_info": "", # 自定义启动项信息
"auto_backup_flag": False, # 是否开启自动备份
"auto_backup_time_limit": 3600 # 自动备份时间间隔(秒)
}
Expand Down
94 changes: 73 additions & 21 deletions ui/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1455</width>
<width>1452</width>
<height>765</height>
</rect>
</property>
Expand Down Expand Up @@ -247,6 +247,9 @@
</property>
</widget>
<widget class="QTextBrowser" name="text_browser_rcon_server">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>20</x>
Expand All @@ -255,6 +258,12 @@
<height>360</height>
</rect>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="button_send_command">
<property name="geometry">
Expand Down Expand Up @@ -373,7 +382,7 @@
<x>880</x>
<y>10</y>
<width>200</width>
<height>401</height>
<height>430</height>
</rect>
</property>
<property name="title">
Expand Down Expand Up @@ -531,7 +540,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>340</y>
<y>370</y>
<width>75</width>
<height>20</height>
</rect>
Expand All @@ -544,7 +553,7 @@
<property name="geometry">
<rect>
<x>110</x>
<y>340</y>
<y>370</y>
<width>75</width>
<height>20</height>
</rect>
Expand All @@ -557,7 +566,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>370</y>
<y>400</y>
<width>75</width>
<height>20</height>
</rect>
Expand All @@ -570,7 +579,7 @@
<property name="geometry">
<rect>
<x>110</x>
<y>370</y>
<y>400</y>
<width>75</width>
<height>20</height>
</rect>
Expand Down Expand Up @@ -672,14 +681,40 @@
<string>是否开启内存超 % 重启</string>
</property>
</widget>
<widget class="QCheckBox" name="check_box_launch_options">
<property name="geometry">
<rect>
<x>10</x>
<y>340</y>
<width>180</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>启动项</string>
</property>
</widget>
<widget class="QLineEdit" name="line_edit_launch_options">
<property name="geometry">
<rect>
<x>70</x>
<y>340</y>
<width>120</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>-EpicAPP=PalServer</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_4">
<property name="geometry">
<rect>
<x>880</x>
<y>420</y>
<y>450</y>
<width>200</width>
<height>291</height>
<height>260</height>
</rect>
</property>
<property name="title">
Expand All @@ -703,7 +738,7 @@
<rect>
<x>10</x>
<y>60</y>
<width>81</width>
<width>80</width>
<height>20</height>
</rect>
</property>
Expand All @@ -730,7 +765,7 @@
<x>10</x>
<y>80</y>
<width>180</width>
<height>50</height>
<height>40</height>
</rect>
</property>
<property name="html">
Expand All @@ -748,7 +783,7 @@ p, li { white-space: pre-wrap; }
<property name="geometry">
<rect>
<x>10</x>
<y>260</y>
<y>230</y>
<width>180</width>
<height>20</height>
</rect>
Expand Down Expand Up @@ -787,8 +822,8 @@ p, li { white-space: pre-wrap; }
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>81</width>
<y>120</y>
<width>80</width>
<height>20</height>
</rect>
</property>
Expand All @@ -800,9 +835,9 @@ p, li { white-space: pre-wrap; }
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<y>140</y>
<width>180</width>
<height>100</height>
<height>80</height>
</rect>
</property>
<property name="html">
Expand Down Expand Up @@ -861,7 +896,7 @@ p, li { white-space: pre-wrap; }
</rect>
</property>
<property name="text">
<string>在线人数 :</string>
<string>在线人数 :</string>
</property>
</widget>
<widget class="QLabel" name="label_online_player">
Expand Down Expand Up @@ -1125,7 +1160,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>1455</width>
<width>1452</width>
<height>21</height>
</rect>
</property>
Expand Down Expand Up @@ -1269,7 +1304,7 @@ p, li { white-space: pre-wrap; }
<hints>
<hint type="sourcelabel">
<x>941</x>
<y>389</y>
<y>420</y>
</hint>
<hint type="destinationlabel">
<x>1447</x>
Expand All @@ -1285,7 +1320,7 @@ p, li { white-space: pre-wrap; }
<hints>
<hint type="sourcelabel">
<x>1035</x>
<y>386</y>
<y>420</y>
</hint>
<hint type="destinationlabel">
<x>1447</x>
Expand All @@ -1301,7 +1336,7 @@ p, li { white-space: pre-wrap; }
<hints>
<hint type="sourcelabel">
<x>932</x>
<y>412</y>
<y>450</y>
</hint>
<hint type="destinationlabel">
<x>1447</x>
Expand All @@ -1317,7 +1352,7 @@ p, li { white-space: pre-wrap; }
<hints>
<hint type="sourcelabel">
<x>1020</x>
<y>415</y>
<y>450</y>
</hint>
<hint type="destinationlabel">
<x>1447</x>
Expand Down Expand Up @@ -1581,6 +1616,22 @@ p, li { white-space: pre-wrap; }
</hint>
</hints>
</connection>
<connection>
<sender>check_box_launch_options</sender>
<signal>clicked(bool)</signal>
<receiver>MainWindow</receiver>
<slot>check_box_launch_options_click()</slot>
<hints>
<hint type="sourcelabel">
<x>918</x>
<y>382</y>
</hint>
<hint type="destinationlabel">
<x>1449</x>
<y>486</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>button_select_file_click()</slot>
Expand Down Expand Up @@ -1608,5 +1659,6 @@ p, li { white-space: pre-wrap; }
<slot>timed_detection_timer_60000()</slot>
<slot>button_edit_settings_click()</slot>
<slot>button_edit_server_name_click()</slot>
<slot>check_box_launch_options_click()</slot>
</slots>
</ui>

0 comments on commit 54e9c61

Please sign in to comment.