switched to single HTML file by hiding certain regions

This commit is contained in:
Aidan Campbell 2016-02-14 20:33:10 -05:00
parent c9e65715cb
commit b634ab84f1
4 changed files with 56 additions and 24 deletions

View File

@ -1,8 +1,6 @@
// just start the app in fullscreen
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
'bounds': {
'width': 400,
'height': 500
}
state: "fullscreen",
});
});

View File

@ -4,38 +4,36 @@
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title>Moonlight</title>
<script type="text/javascript" src="index.js"></script>
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body data-name="moonlight-chrome" data-width="1280" data-height="720" data-tools="pnacl" data-configs="Debug Release" data-path="{tc}/{config}">
<div id="title">
<h1>Moonlight Streaming</h1>
<h2>Chrome App Status: <code id="statusField">NO-STATUS</code></h2>
<p></p>
<code id="logField">log</code>
</div>
<code id="logField">log</code>
<p>Enter the IP/hostname of the GFE streaming computer, or select one from the history:</p>
<input type="text" size="15" id="GFEHostIPField" value="127.0.0.1">
<div id="streamSettings" style="display:none"></div>
<select id="selectHost">
<option value="">No history available</option>
</select>
<p></p>
<button id="pairButton">Pair</button>
<button id="showAppsButton">Retrieve App List</button>
<p></p>
<div id="hostSettings">
<p>Enter the IP/hostname of the GFE streaming computer, or select one from the history:</p>
<input type="text" size="15" id="GFEHostIPField" value="127.0.0.1">
<select id="selectHost">
<option value="">No history available</option>
</select>
<p></p>
<button id="pairButton">Pair</button>
<button id="showAppsButton">Retrieve App List</button>
</div>
<div id="testingDiv" style="border:3px solid red">
<button id="startButton">Start Testing Stuff</button>
<button id="stopButton">Stop Testing Stuff</button>
</div>
<div hidden id="gameSelectionDiv">
<div id="gameSelection" style="display:none">
<p>Select a game to run</p>
<select id="selectGame">
<option value="game_id_1">Game Name 1</option>

View File

@ -6,6 +6,22 @@ function attachListeners() {
document.getElementById('showAppsButton').addEventListener('click', showAppsPushed);
}
function moduleDidLoad() {
common.naclModule = document.getElementById('nacl_module');
var logEl = document.getElementById('logField');
logEl.innerHTML = "module loaded";
}
// we want the user to progress through the streaming process
// but to save from the PITA of inter-chrome-app-page JS message passing,
// I'm opting to
function hideAllWorkflowDivs() {
document.getElementById('streamSettings').style.display = 'inline-block';
document.getElementById('hostSettings').style.display = 'inline-block';
document.getElementById('gameSelection').style.display = 'none';
document.getElementById('listener').style.display = 'none';
}
// pair button was pushed. pass what the user entered into the GFEHostIPField.
function pairPushed() {
common.naclModule.postMessage('pair:' + document.getElementById('GFEHostIPField').value);
@ -21,7 +37,11 @@ function showAppsPushed() {
target = e.options[e.selectedIndex].value;
}
common.naclModule.postMessage('showAppsPushed:' + target);
document.getElementById("gameSelectionDiv").style.display = "visible";
// we just finished the hostSettings section. expose the next one
document.getElementById('streamSettings').style.display = 'none';
document.getElementById('hostSettings').style.display = 'none'
document.getElementById('gameSelection').style.display = 'inline-block'
document.getElementById('listener').style.display = 'none'
}
// user wants to start a stream. We need the host, game ID, and video settings(?)
@ -35,6 +55,14 @@ function startPushed() {
var gameIDDropdown = document.getElementById("selectGame");
var gameID = gameIDDropdown[gameIDDropdown.selectedIndex].value;
common.naclModule.postMessage('setGFEHostIPField:' + target + ":" + gameID);
// we just finished the gameSelection section. only expose the NaCl section
document.getElementById('streamSettings').style.display = 'none';
document.getElementById('hostSettings').style.display = 'none';
document.getElementById('gameSelection').style.display = 'none'
document.getElementById('testingDiv').style.display = 'none'
document.getElementById('listener').style.display = 'inline-block'
document.getElementById('title').style.display = 'none'
}
// user pushed the stop button. we should stop.
@ -47,3 +75,5 @@ function handleMessage(msg) {
var logEl = document.getElementById('logField');
logEl.innerHTML = msg.data;
}
// window.onload = hideAllWorkflowDivs;

View File

@ -87,16 +87,21 @@ void MoonlightInstance::HandleMessage(const pp::Var& var_message) {
} else if (strncmp(message.c_str(), STOP_DIRECTIVE, strlen(STOP_DIRECTIVE)) == 0) {
handleStopStream(message);
} else {
// :(
pp::Var response("Unhandled message received: " + message);
PostMessage(response);
}
}
void MoonlightInstance::handlePair(std::string pairMessage) {
pp::Var response("Pair button pushed. Pairing is unimplemented.");
PostMessage(response);
std::string intendedHost = pairMessage.substr(pairMessage.find(PAIR_DIRECTIVE) + strlen(PAIR_DIRECTIVE));
}
void MoonlightInstance::handleShowGames(std::string showGamesMessage) {
pp::Var response("Show Games button pushed. Show Games is unimplemented");
PostMessage(response);
std::string host = showGamesMessage.substr(showGamesMessage.find(SHOW_GAMES_DIRECTIVE) + strlen(SHOW_GAMES_DIRECTIVE));
}
@ -119,7 +124,7 @@ void MoonlightInstance::handleStartStream(std::string startStreamMessage) {
std::string gameID = startStreamMessage.substr(startStreamMessage.find(host) + host.length() + 1); // +1 for the colon delimiter
// Post a status update before we begin
pp::Var response("Starting connection...");
pp::Var response("Starting connection to " + host + " to play game ID " + gameID);
PostMessage(response);
// Start the worker thread to establish the connection
@ -128,7 +133,8 @@ void MoonlightInstance::handleStartStream(std::string startStreamMessage) {
}
void MoonlightInstance::handleStopStream(std::string stopStreamMessage) {
pp::Var response("Stop button pushed. Ignoring.");
PostMessage(response);
}
bool MoonlightInstance::Init(uint32_t argc,