2.2k
919
554
MIT License

深度技术解读

GitHub 仓库 Aloshi/EmulationStation 深度技术分析

项目背景与痛点

EmulationStation 是一个灵活的介绍性前端,用于支持键盘导航以及自定义系统主题。这款工具的出现,解决了一些游戏模拟器在使用体验上的痛点,特别是对于那些缺少实体键盘的游戏机来说,用户无需手动配置就能获得流畅的导航体验。那些从实体游戏机转移到电视频道或便携式设备的用户往往面临着相同的挑战——没有实体键盘,如何轻松地在众多游戏之间切换?答案就在 EmulationStation 中。

游戏模拟器虽然在背后的技术层面可以实现多样性的游戏运行环境,但其界面设计和用户交互方面始终欠缺人性化设计。尤其是对于那些原本已经形成不同设备使用习惯的用户来说,重新学习如何在没有物理键盘的情况下操作日渐式的菜单导航无疑是一个难题。而 EmulationStation 恰好满足了这一需求,它在实现了高效、准确地访问大量模拟游戏的过程中,将界面设计推向了一个崭新的高度。

核心技术揭秘

技术栈

EmulationStation 的主要技术栈包括:

  • Node.js:用于客户端代码的构建,进行易于维护和扩展的前端框架。
  • Electron:作为应用框架,实现了跨平台的开发和部署,提高开发效率。
  • JSON 配置文件:用于存储系统和游戏的配置信息,使用户可以轻松地对各种模拟器进行配置。
  • Bash脚本:用于与游戏模拟器进行交互,自动执行游戏安装和启动操作。
  • 图形界面:结合多种流行的图形库(例如 GTK+、Qt 或者 Curses),实现自定义主题和丰富的用户界面。

实现原理

  • 依赖管理:利用 npm 和 package.json 文件来管理项目中的依赖。通过这种方式可以确保所有开发环境下使用的库版本一致性,保证稳定性。
  • 代码组织:遵循模块化设计原则,将不同的功能模块(如系统检测、界面配置、游戏安装等)抽象成独立的类或函数,便于维护和扩展。
  • 导航优化:通过自定义的键盘组合键,优化菜单导航体验,使得用户在没有实体键盘的情况下也能流畅地浏览和选择游戏。

核心算法

  • 实时监控:通过实时监控系统信息来确保新游戏或模拟器的配置及时更新,确保用户始终拥有最新和最完善的游戏库。
  • 自定义主题:利用 CSS 和 JavaScript 技术,允许用户自由选择和创建自己的主题,从而适应不同的偏好和环境。
  • 多语言支持:内置多国语言的本地化处理机制,支持用户根据自身需要自由切换,从而提供更广泛的国际用户群体覆盖。

功能亮点与差异

  • 键盘操作的可配置性:允许用户根据自己的操作习惯来自定义虚拟键盘布局和按键组合,为没有实体键盘的设备提供了更加人性化的操作方式。
  • 自定义主题支持:用户可以轻松地修改或创建自己的主题,以适应不同的使用场景或视觉偏好。
  • 本地化语言支持:提供了多语言支持,增强产品的适应性和国际化能力。
  • 灵活的游戏管理:支持多种方式(如脚本自动化、Bash 脚本等)添加和管理游戏,增加用户的便利性。

应用场景与落地建议

应用场景

  • 家庭娱乐系统:对于那些希望将多种游戏体验整合到一个平台中的家庭用户来说,EmulationStation 提供了一个强大的解决方案。
  • 教育场景:作为教育工具,能够帮助老师将不同年代的游戏轻松搬上课堂,以辅助教学活动。
  • 数字媒体盒:对于希望在没有实体键盘的情况下为用户提供丰富游戏体验的开发者来说,EmulationStation 是一个不错的选择。

落地建议

  • 开发配适性:考虑到跨平台的需求,开发者应尽量编写通用性强的代码,并准确地理解不同操作系统和架构上的差异。
  • 监控与社区支持:开发团队应积极维护项目,确保及时发布更新和改进整个平台。建立良好的社区交流,使得用户可以得到及时的帮助和支持。
  • 硬件适配:对于硬件发烧友来说,进一步改进对 DLNA、MAME 等设备的支持。

综合评价

EmulationStation 在通过自定义系统主题和丰富的可配置导航方式等方面的创新设计,深入解决了一些用户长期苦恼的问题,特别是在满足用户游戏设备多样化需求的同时,还为社区成员的贡献提供了友好的环境。然而,仅凭现有的技术架构还存在一些问题,主要体现在对最新云技术的支持,以及对不同语言环境的本地化处理。总体来说,EmulationStation 是一个具有创新性和实用性的项目,值得开发者进一步进行研究和优化。

简要分析

热度分
6284
价值分
1804
活跃状态
活跃
主题数量
0
语言C++
默认分支
大小0 KB
更新
暂无主题

编辑推荐

社区关注度与协作度较高,适合实践与生产使用。

C++ActiveMIT License

语言占比

C++
CMake

Release

README

EmulationStation

A cross-platform graphical front-end for emulators with controller navigation.

Project website: http://emulationstation.org

Raspberry Pi users:
A cool guy named petrockblog made a script which automatically installs many emulators and ES. It also includes options for configuring your RPi and setting it up to boot directly into ES. You can find it here: https://github.com/petrockblog/RetroPie-Setup

Download

Download a pre-compiled version at emulationstation.org.

I found a bug! I have a problem!

  • First, try to check the issue list for some entries that might match your problem. Make sure to check closed issues too!

  • If you’re running EmulationStation on a on Raspberry Pi and have problems with config file changes not taking effect, content missing after editing, etc., check if your SD card is corrupted (see issues #78 and #107). You can do this with free tools like h2testw or F3.

  • Try to update to the latest version of EmulationStation using git (you might need to delete your es_input.cfg and es_settings.cfg after that to reset them to default values):

cd YourEmulationStationDirectory
git pull
cmake .
make
  • If your problem still isn’t gone, the best way to report a bug is to post an issue on GitHub. Try to post the simplest steps possible to reproduce the bug. Include files you think might be related (except for ROMs, of course). If you haven’t re-run ES since the crash, the log file ~/.emulationstation/es_log.txt is also helpful.

Building

EmulationStation uses some C++11 code, which means you’ll need to use at least g+±4.7 on Linux, or VS2010 on Windows, to compile.

EmulationStation has a few dependencies. For building, you’ll need CMake, SDL2, Boost (System, Filesystem, DateTime, Locale), FreeImage, FreeType, Eigen3, and cURL. You also should probably install the fonts-droid package which contains fallback fonts for Chinese/Japanese/Korean characters, but ES will still work fine without it (this package is only used at run-time).

On Debian/Ubuntu:
All of this be easily installed with apt-get:

sudo apt-get install libsdl2-dev libboost-system-dev libboost-filesystem-dev libboost-date-time-dev libboost-locale-dev libfreeimage-dev libfreetype6-dev libeigen3-dev libcurl4-openssl-dev libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid

Then, generate and build the Makefile with CMake:

cd YourEmulationStationDirectory
cmake .
make

On the Raspberry Pi:

Complete Raspberry Pi build instructions at emulationstation.org.

On Windows:

Boost (you’ll need to compile yourself or get the pre-compiled binaries)

Eigen3 (header-only library)

FreeImage

FreeType2 (you’ll need to compile)

SDL2

cURL (you’ll need to compile or get the pre-compiled DLL version)

(Remember to copy necessary .DLLs into the same folder as the executable: probably FreeImage.dll, freetype6.dll, SDL2.dll, libcurl.dll, and zlib1.dll. Exact list depends on if you built your libraries in “static” mode or not.)

CMake (this is used for generating the Visual Studio project)

(If you don’t know how to use CMake, here are some hints: run cmake-gui and point it at your EmulationStation folder. Point the “build” directory somewhere - I use EmulationStation/build. Click configure, choose “Visual Studio [year] Project”, fill in red fields as they appear and keep clicking Configure (you may need to check “Advanced”), then click Generate.)

Configuring

~/.emulationstation/es_systems.cfg:
When first run, an example systems configuration file will be created at ~/.emulationstation/es_systems.cfg. ~ is $HOME on Linux, and %HOMEPATH% on Windows. This example has some comments explaining how to write the configuration file. See the “Writing an es_systems.cfg” section for more information.

Keep in mind you’ll have to set up your emulator separately from EmulationStation!

~/.emulationstation/es_input.cfg:
When you first start EmulationStation, you will be prompted to configure an input device. The process is thus:

  1. Hold a button on the device you want to configure. This includes the keyboard.

  2. Press the buttons as they appear in the list. Some inputs can be skipped by holding any button down for a few seconds (e.g. page up/page down).

  3. You can review your mappings by pressing up and down, making any changes by pressing A.

  4. Choose “SAVE” to save this device and close the input configuration screen.

The new configuration will be added to the ~/.emulationstation/es_input.cfg file.

Both new and old devices can be (re)configured at any time by pressing the Start button and choosing “CONFIGURE INPUT”. From here, you may unplug the device you used to open the menu and plug in a new one, if necessary. New devices will be appended to the existing input configuration file, so your old devices will remain configured.

If your controller stops working, you can delete the ~/.emulationstation/es_input.cfg file to make the input configuration screen re-appear on next run.

You can use --help or -h to view a list of command-line options. Briefly outlined here:

--resolution [width] [height]	- try and force a particular resolution
--gamelist-only		- only display games defined in a gamelist.xml file.
--ignore-gamelist	- do not parse any gamelist.xml files.
--draw-framerate	- draw the framerate.
--no-exit		- do not display 'exit' in the ES menu.
--debug			- show the console window on Windows, do slightly more logging
--windowed	- run ES in a window, works best in conjunction with --resolution [w] [h].
--vsync [1/on or 0/off]	- turn vsync on or off (default is on).
--scrape	- run the interactive command-line metadata scraper.

As long as ES hasn’t frozen, you can always press F4 to close the application.

Writing an es_systems.cfg

Complete configuration instructions at emulationstation.org.

The es_systems.cfg file contains the system configuration data for EmulationStation, written in XML. This tells EmulationStation what systems you have, what platform they correspond to (for scraping), and where the games are located.

ES will check two places for an es_systems.cfg file, in the following order, stopping after it finds one that works:

  • ~/.emulationstation/es_systems.cfg
  • /etc/emulationstation/es_systems.cfg

The order EmulationStation displays systems reflects the order you define them in.

NOTE: A system must have at least one game present in its “path” directory, or ES will ignore it! If no valid systems are found, ES will report an error and quit!

Here’s an example es_systems.cfg:

<!-- This is the EmulationStation Systems configuration file.
All systems must be contained within the <systemList> tag.-->

<systemList>
	<!-- Here's an example system to get you started. -->
	<system>
		<!-- A short name, used internally. -->
		<name>snes</name>

		<!-- A "pretty" name, displayed in the menus and such. This one is optional. -->
		<fullname>Super Nintendo Entertainment System</fullname>

		<!-- The path to start searching for ROMs in. '~' will be expanded to $HOME or %HOMEPATH%, depending on platform.
		All subdirectories (and non-recursive links) will be included. -->
		<path>~/roms/snes</path>

		<!-- A list of extensions to search for, delimited by any of the whitespace characters (", \r\n\t").
		You MUST include the period at the start of the extension! It's also case sensitive. -->
		<extension>.smc .sfc .SMC .SFC</extension>

		<!-- The shell command executed when a game is selected. A few special tags are replaced if found in a command, like %ROM% (see below). -->
		<command>snesemulator %ROM%</command>
		<!-- This example would run the bash command "snesemulator /home/user/roms/snes/Super\ Mario\ World.sfc". -->

		<!-- The platform(s) to use when scraping. You can see the full list of accepted platforms in src/PlatformIds.cpp.
		It's case sensitive, but everything is lowercase. This tag is optional.
		You can use multiple platforms too, delimited with any of the whitespace characters (", \r\n\t"), eg: "genesis, megadrive" -->
		<platform>snes</platform>

		<!-- The theme to load from the current theme set. See THEMES.md for more information.
		This tag is optional; if not set, it will use the value of <name>. -->
		<theme>snes</theme>
	</system>
</systemList>

The following “tags” are replaced by ES in launch commands:

%ROM% - Replaced with absolute path to the selected ROM, with most Bash special characters escaped with a backslash.

%BASENAME% - Replaced with the “base” name of the path to the selected ROM. For example, a path of “/foo/bar.rom”, this tag would be “bar”. This tag is useful for setting up AdvanceMAME.

%ROM_RAW% - Replaced with the unescaped, absolute path to the selected ROM. If your emulator is picky about paths, you might want to use this instead of %ROM%, but enclosed in quotes.

See SYSTEMS.md for some live examples in EmulationStation.

gamelist.xml

The gamelist.xml file for a system defines metadata for games, such as a name, image (like a screenshot or box art), description, release date, and rating.

If at least one game in a system has an image specified, ES will use the detailed view for that system (which displays metadata alongside the game list).

You can use ES’s scraping tools to avoid creating a gamelist.xml by hand. There are two ways to run the scraper:

  • If you want to scrape multiple games: press start to open the menu and choose the “SCRAPER” option. Adjust your settings and press “SCRAPE NOW”.
  • If you just want to scrape one game: find the game on the game list in ES and press select. Choose “EDIT THIS GAME’S METADATA” and then press the “SCRAPE” button at the bottom of the metadata editor.

You can also edit metadata within ES by using the metadata editor - just find the game you wish to edit on the gamelist, press Select, and choose “EDIT THIS GAME’S METADATA.”

A command-line version of the scraper is also provided - just run emulationstation with --scrape (currently broken).

The switch --ignore-gamelist can be used to ignore the gamelist and force ES to use the non-detailed view.

If you’re writing a tool to generate or parse gamelist.xml files, you should check out GAMELISTS.md for more detailed documentation.

Themes

By default, EmulationStation looks pretty ugly. You can fix that. If you want to know more about making your own themes (or editing existing ones), read THEMES.md!

I’ve put some themes up for download on my EmulationStation webpage: http://aloshi.com/emulationstation#themes

If you’re using RetroPie, you should already have a nice set of themes automatically installed!

-Alec “Aloshi” Lofquist
http://www.aloshi.com
http://www.emulationstation.org

评论

暂无评论