public IniSection getIniSection(String sectionName) { return iniSettingFile.getSection(sectionName); }
public PlayClient() throws IOException { iniSettingFile = new IniFile(INI_SETTING_FILE_NAME); iniAppDataFile = new IniFile(INI_APPDATA_FILE_NAME); iniSettings = new IniSettings(iniSettingFile.getSection(IniSettings.SECTION), new WlanProxyLibrary(this)); iniUserProfile = new IniUserProfile(iniSettingFile.getSection(IniUserProfile.SECTION)); iniAppearance = new IniAppearance(iniSettingFile.getSection(IniAppearance.SECTION)); iniAppData = new IniAppData(iniAppDataFile.getSection(null)); ArrayList<String> pendingLogs = new ArrayList<String>(); if (JnetPcapWlanDevice.LIBRARY.isReady()) { pendingLogs.add("PcapインストールOK"); } else { pendingLogs.add("Pcapがインストールされていません"); } if (NativeWlanDevice.LIBRARY.isReady()) { pendingLogs.add("Windowsワイヤレスネットワーク機能OK"); } else { pendingLogs.add("Windowsワイヤレスネットワーク機能がインストールされていません"); } wlanLibrary = iniSettings.getWlanLibrary(); ILogger logger = new ILogger() { @Override public void log(String message) { getArenaWindow().appendToSystemLog(message, true); } }; tcpClient = new AsyncTcpClient(logger, 1000000, 0); udpClient = new AsyncUdpClient(logger); imageRegistry = new ImageRegistry(SwtUtils.DISPLAY); colorRegistry = new ColorRegistry(SwtUtils.DISPLAY); clipboard = new Clipboard(SwtUtils.DISPLAY); try { Image icon16 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue16.png")); Image icon32 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue32.png")); Image icon48 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue48.png")); Image icon96 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue96.png")); imageRegistry.put(ICON_APP16, icon16); imageRegistry.put(ICON_APP32, icon32); imageRegistry.put(ICON_APP48, icon48); imageRegistry.put(ICON_APP96, icon96); shellImages = new Image[] {icon16, icon32, icon48, icon96}; Image toolArena = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/search.png")); Image toolRoom = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/lobby4.png")); Image toolConfig = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/config.png")); Image toolLog = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/log.png")); Image toolWiki = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/wiki.png")); Image toolExit = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/lobby3.png")); imageRegistry.put(ICON_TOOLBAR_ARENA, toolArena); imageRegistry.put(ICON_TOOLBAR_ROOM, toolRoom); imageRegistry.put(ICON_TOOLBAR_LOG, toolLog); imageRegistry.put(ICON_TOOLBAR_WIKI, toolWiki); imageRegistry.put(ICON_TOOLBAR_CONFIG, toolConfig); imageRegistry.put(ICON_TOOLBAR_EXIT, toolExit); Image tabLobby = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/lobby.png")); Image tabLobbyNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/lobby2.png")); Image tabSystem = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/log.png")); Image tabSystemNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/log2.png")); Image tabPm = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/pm.png")); Image tabPmNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/pm2.png")); Image tabCircle = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/circle.png")); Image tabCircleNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/circle2.png")); imageRegistry.put(ICON_TAB_LOBBY, tabLobby); imageRegistry.put(ICON_TAB_LOBBY_NOTIFY, tabLobbyNotify); imageRegistry.put(ICON_TAB_LOG, tabSystem); imageRegistry.put(ICON_TAB_LOG_NOTIFY, tabSystemNotify); imageRegistry.put(ICON_TAB_PM, tabPm); imageRegistry.put(ICON_TAB_PM_NOTIFY, tabPmNotify); imageRegistry.put(ICON_TAB_CIRCLE, tabCircle); imageRegistry.put(ICON_TAB_CIRCLE_NOTIFY, tabCircleNotify); } catch (SWTException e) { } colorRegistry.put(COLOR_OK, new RGB(0, 140, 0)); colorRegistry.put(COLOR_NG, new RGB(200, 0, 0)); colorRegistry.put(COLOR_APP_NUMBER, new RGB(0, 0, 220)); colorRegistry.put(COLOR_TAB_NOTIFY, new RGB(0, 0, 220)); arenaWindow = new ArenaWindow(this); try { Tray systemTray = SwtUtils.DISPLAY.getSystemTray(); if (systemTray != null) { trayItem = new TrayItem(systemTray, SWT.NONE); trayItem.setImage(imageRegistry.get(ICON_APP16)); trayItem.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { arenaWindow.show(); if (roomWindow != null) roomWindow.show(); } }); toolTip = new ToolTip(arenaWindow.getShell(), SWT.BALLOON | SWT.ICON_INFORMATION); trayItem.setToolTip(toolTip); trayItem.setToolTipText(AppConstants.APP_NAME); final Menu menu = new Menu(arenaWindow.getShell()); MenuItem itemArena = new MenuItem(menu, SWT.PUSH); itemArena.setText("アリーナ"); itemArena.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { getArenaWindow().show(); } }); MenuItem itemRoom = new MenuItem(menu, SWT.PUSH); itemRoom.setText("ルーム"); itemRoom.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { getRoomWindow().show(); } }); MenuItem itemShutdown = new MenuItem(menu, SWT.PUSH); itemShutdown.setText("アプリを終了"); itemShutdown.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { isRunning = false; } }); trayItem.addMenuDetectListener( new MenuDetectListener() { @Override public void menuDetected(MenuDetectEvent e) { menu.setVisible(true); } }); } } catch (SWTException e) { } try { serverRegistry = new IniPublicServerRegistry(); } catch (IOException e) { serverRegistry = IServerRegistry.NULL; arenaWindow.appendToSystemLog(Utility.stackTraceToString(e), true); } portalServerList = serverRegistry.getPortalRotator(); String software = String.format("%s プレイクライアント バージョン: %s", AppConstants.APP_NAME, AppConstants.VERSION); arenaWindow.appendToSystemLog(software, false); arenaWindow.appendToSystemLog("プロトコル: " + IProtocol.NUMBER, false); for (String log : pendingLogs) { arenaWindow.appendToSystemLog(log, false); } Thread cronThread = new Thread( new Runnable() { @Override public void run() { try { while (!SwtUtils.DISPLAY.isDisposed()) { arenaWindow.cronJob(); if (roomWindow != null) roomWindow.cronJob(); Thread.sleep(1000); } } catch (InterruptedException e) { } catch (SWTException e) { } } }, "CronThread"); cronThread.setDaemon(true); cronThread.start(); try { IPlugin plugin = (IPlugin) Class.forName(BouyomiChanPlugin.class.getName()).newInstance(); plugin.initPlugin(this); pluginList.add(plugin); } catch (InstantiationException e) { } catch (IllegalAccessException e) { } catch (ClassNotFoundException e) { } arenaWindow .getShell() .addShellListener( new ShellListener() { @Override public void shellActivated(ShellEvent e) {} @Override public void shellIconified(ShellEvent e) {} @Override public void shellDeiconified(ShellEvent e) {} @Override public void shellDeactivated(ShellEvent e) {} @Override public void shellClosed(ShellEvent e) { if (roomWindow == null || !roomWindow.getShell().getVisible()) { checkApplicationShutdown(arenaWindow.getShell(), e); } else { e.doit = false; arenaWindow.hide(); } } }); if (Utility.isEmpty(iniUserProfile.getUserName())) { TextDialog dialog = new TextDialog( null, AppConstants.APP_NAME + " - ユーザー名が設定されていません", "ユーザー名を入力してください", null, 300, SWT.NONE); switch (dialog.open()) { case IDialogConstants.OK_ID: iniUserProfile.setUserName(dialog.getUserInput()); break; default: iniUserProfile.setUserName("未設定"); } } if (iniSettings.isStartupWindowArena()) { arenaWindow.show(); } else { getRoomWindow().show(); } }