Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ STILL WIP ] Bug Fixes & Additions to Wii Shop Channel #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion channelart/electron/channel.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@


#p1 {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
width: 100vw;
height: 100vh;
Expand Down Expand Up @@ -86,7 +89,7 @@
<body>

<div id="p1">
<img class="banner" src="banner.png" style="width: 100%;">
<img class="banner" src="banner.png" style="height: 100%;">
</div>

<div id="p2">
Expand Down
14 changes: 12 additions & 2 deletions css/shop.css
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ h2 {color: #333}
.title-container {
border: 1px var(--blue) solid;
padding: 10px;
padding-top: 26px;
width: 92%;
height: 238px;
margin: auto;
Expand Down Expand Up @@ -192,11 +191,15 @@ h2 {color: #333}
}

.titles .product .below span {
height: 18px;
max-height: 18px;
font-size: 14px;
line-height: 18px;
}

.titles .product .below .desc {
font-size: 10px;
}

.titles .product .spacer {
background: var(--blue);
margin: 0;
Expand All @@ -211,7 +214,9 @@ h2 {color: #333}
}

.titles .product .info {
min-height: 72px;
margin-left: 6px;
position: relative;
}

.titles .product .title {
Expand All @@ -223,6 +228,11 @@ h2 {color: #333}
line-height: 16px;
overflow: hidden;
}
.titles[category="settings"] .product .title {
height: auto;
position: absolute;
top: 35%;
}

.rename-header {
display: none;
Expand Down
1 change: 1 addition & 0 deletions db/shopitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ setTimeout(() => {
}
],
downloaded: userChannels,
defaults: defaultChannels
}
}, 100);
37 changes: 29 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,26 @@
// Add channels that user has in their channel storage.
window.addEventListener('load', () => {
// For each user channel
// (userChannels is defined in 'config.js')
for (const channel of userChannels) {
// (defaultChannels is defined in 'config.js')
for (const channel of defaultChannels) {
// Send info to makeChannel
makeChannel(channel);
}
mainchannelsset = true;
});

// Add channels that user has in their channel storage.
window.addEventListener('load', () => {
// For each user channel
// (userChannels is defined in 'config.js')
if (userChannels && userChannels.length > 0) {
for (const channel of userChannels) {
// Send info to makeChannel
makeChannel(channel);
}
}
});

// Start the clock
startDateTime();

Expand Down Expand Up @@ -248,7 +260,16 @@ <h2><div class="warn-icon">&#9888;&nbsp;</div>WARNING-HEALTH AND SAFETY</h3>
$(document).on("click", ".occupied", function() {
console.log(`current channel:`, $(this).data('id'));
// Get channel from channel confg to find assets folder
var targetChannel = null;
let targetChannel = null;
// First try to find the channel in the defaultChannels
for (let i = 0; i < defaultChannels.length; i++) {
const element = defaultChannels[i];

if (element.id == $(this).data('id')) {
targetChannel = element;
}
}
// Try to find the channel in userChannels
for (let i = 0; i < userChannels.length; i++) {
const element = userChannels[i];

Expand Down Expand Up @@ -277,25 +298,25 @@ <h2><div class="warn-icon">&#9888;&nbsp;</div>WARNING-HEALTH AND SAFETY</h3>
console.log($(this).data('special'));
// This is what should really happen.
} else {
alert(`The '${$(this).data('id')}' channel couldn't be found in the channel config!`);
alert(`The '${$(this).data('id')}' channel couldn't be found in the default & user channel config!`);
}
}

// Audio
var audiosrc = targetChannel.assets + $(this).data('id') + '/audio.mp3';
let audiosrc = targetChannel.assets + $(this).data('id') + '/audio.mp3';
$("#chSpec").attr('src', audiosrc);
// Video
// If this channel has a "videoformat"
var vformat = 'gif';
let vformat = 'gif';
if (targetChannel.videoformat) {
vformat = targetChannel.videoformat
}
var videosrc = targetChannel.assets + $(this).data('id') + `/video.${vformat}`;
let videosrc = targetChannel.assets + $(this).data('id') + `/video.${vformat}`;
$("#videoSpec").attr('src', videosrc);

// Start channel music
$("#chSpec")[0].currentTime = 0;
var currentaudio = document.getElementById("chSpec");
let currentaudio = document.getElementById("chSpec");
currentaudio.play();

// Move into channel
Expand Down
2 changes: 1 addition & 1 deletion js/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function bgMusicIntroToggle(forceToggle) {
// Get bgMusic state
function getBGMusicState() {
return {
intro: introBgMusic.playing(),
intro: introBgMusic ? introBgMusic.playing() : false,
main: bgMusic.playing()
};
}
Expand Down
104 changes: 91 additions & 13 deletions js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var def_channels = [
title: 'Wii Shop Channel',
assets: 'assets/channels/',
channelart: 'channelart/',
target: '/shop/index.html'
target: 'shop/index.html'
},
{
id: 'news',
Expand All @@ -63,33 +63,111 @@ var def_channels = [
}
]

// Set channels if they aren't set
// Instead of setting the default channels in say "userChannels", we'll put them in a different item in Local Storage.
// This way we can make sure everything goes wrong in there and not have to worry about the defaults not working.
// Also check for items that possibly don't exist.
if (!localStorage.getItem('onliine-default-channels')) {
localStorage.setItem("onliine-default-channels", JSON.stringify(def_channels));
}
if (!localStorage.getItem('onliine-igrore-default-channels')) {
localStorage.setItem("onliine-ignore-default-channels", JSON.stringify({}));
}
if (!localStorage.getItem('onliine-channels')) {
localStorage.setItem("onliine-channels", JSON.stringify(def_channels));
localStorage.setItem("onliine-channels", JSON.stringify({}));
}
if (!localStorage.getItem('onliine-channel-configs')) {
localStorage.setItem("onliine-channel-configs", JSON.stringify({}));
}

var defaultChannels = JSON.parse(localStorage.getItem('onliine-default-channels'));
var userChannels = JSON.parse(localStorage.getItem('onliine-channels'));
console.log(`user channels: `, userChannels);
var ignoredDefaultChannels = JSON.parse(localStorage.getItem('onliine-igrore-default-channels'));
var channelConfigs = JSON.parse(localStorage.getItem('onliine-channel-configs'));
// From here, we can also check if the item needs changes.
if (JSON.stringify(def_channels) != JSON.stringify(defaultChannels)) {
console.log('Detected changes to default channels!');
localStorage.setItem("onliine-default-channels", JSON.stringify(def_channels));
}
// For older configs (which can be removed after a while)
if (userChannels && userChannels[2] && userChannels[2].id == 'photo') {
localStorage.setItem("onliine-channels", JSON.stringify({}));
location.reload();
}
console.log(`default channels: `, defaultChannels);

// Load default config
function resetConfig(confirm) {

// Reset default channels
function resetDefaultChannels(confirm) {
if (confirm == true) {
// Confirmed! writing...
localStorage.setItem("onliine-settings", JSON.stringify(def_config));
userConfig = JSON.parse(localStorage.getItem('onliine-settings'));
console.log(`user config reset!:`, userConfig);
localStorage.setItem("onliine-default-channels", JSON.stringify(def_channels));
defaultChannels = JSON.parse(localStorage.getItem('onliine-default-channels'));
console.log(`default channels reset! (reload page to see):`, defaultChannels);
} else {
console.error(`loadDefaultConfig: MAKE SURE YOU'D LIKE TO DO THIS BY USING "loadDefaultConfig(true)". THERE'S NO TURNING BACK!!`)
console.error(`resetDefaultChannels: MAKE SURE YOU'D LIKE TO DO THIS BY USING ADDING "true" IN THE FUNCTION. THERE'S NO TURNING BACK!!`)
}
}

// Load default channels
function resetChannels(confirm) {
// Reset user channels
function resetUserChannels(confirm) {
if (confirm == true) {
// Confirmed! writing...
localStorage.setItem("onliine-channels", JSON.stringify(def_channels));
userChannels = JSON.parse(localStorage.getItem('onliine-channels'));
console.log(`user channels reset! (reload page to see):`, userChannels);
} else {
console.error(`loadDefaultChannels: MAKE SURE YOU'D LIKE TO DO THIS BY USING ADDING "true" IN THE FUNCTION. THERE'S NO TURNING BACK!!`)
console.error(`resetUserChannels: MAKE SURE YOU'D LIKE TO DO THIS BY USING ADDING "true" IN THE FUNCTION. THERE'S NO TURNING BACK!!`)
}
}

// Reset ignored default channels
function resetIgnoredChannels(confirm) {
if (confirm == true) {
// Confirmed! writing...
localStorage.setItem("onliine-igrore-default-channels", JSON.stringify(def_channels));
ignoredDefaultChannels = JSON.parse(localStorage.getItem('onliine-igrore-default-channels'));
console.log(`ignored channels reset! (reload page to see):`, ignoredDefaultChannels);
} else {
console.error(`resetIgnoredChannels: MAKE SURE YOU'D LIKE TO DO THIS BY USING ADDING "true" IN THE FUNCTION. THERE'S NO TURNING BACK!!`)
}
}

// Reset channel configs
function resetConfig(confirm) {
if (confirm == true) {
// Confirmed! writing...
localStorage.setItem("onliine-channel-configs", JSON.stringify({}));
channelConfigs = JSON.parse(localStorage.getItem('onliine-channel-configs'));

console.log(`channel configs reset!:`, channelConfigs);
} else {
console.error(`resetConfig: MAKE SURE YOU'D LIKE TO DO THIS BY USING "loadDefaultConfig(true)". THERE'S NO TURNING BACK!!`)
}
}


// Add or edit a value in a channel config
function editChannelConfig(key, value) {
if (channelID) {
if (!channelConfigs[channelID]) {
channelConfigs[channelID] = {};
}
channelConfigs[channelID][key] = value;
console.log(channelConfigs[key]);
localStorage.setItem("onliine-channel-configs", JSON.stringify(channelConfigs));
} else {
alert('There is not "channelID" varaible set. Please add one before trying to edit the channel config!')
}
}

// Get a value from a channel config
function getChannelConfigKey(key) {
if (channelID) {
if (!channelConfigs[channelID]) {
channelConfigs[channelID] = {};
}
return channelConfigs[channelID][key];
} else {
alert('There is not "channelID" varaible set. Please add one before trying to get the channel config!')
}
}
2 changes: 2 additions & 0 deletions shop/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<meta name="keywords" content="riimake,onliine,wii,homebrew,wii simulator,wii menu,wii web" />
<meta name="theme-color" content="#222222" />
<meta name="apple-mobile-web-app-status-bar" content="#222222" />

<script>var channelID = 'shop';</script>
</head>
<body>
<!-- bg -->
Expand Down
Loading