Skip to content

Commit

Permalink
add: multi-platform support
Browse files Browse the repository at this point in the history
This commit adds multi-platform support, re-organizing the repository to accept more platforms.
  • Loading branch information
ThePedroo committed Oct 22, 2023
1 parent eca05ee commit 40290b0
Show file tree
Hide file tree
Showing 15 changed files with 571 additions and 651 deletions.
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import coder from './src/coder.js'
import scene from './src/scene.js'
import subScene from './src/sub-scene.js'
import menu from './src/menu.js'
import achievements from './src/achievements.js'
import custom from './src/custom.js'
import items from './src/items.js'
import coder from './platforms/main/coder.js'
import scene from './platforms/main/scene.js'
import subScene from './platforms/main/sub-scene.js'
import menu from './platforms/main/menu.js'
import achievements from './platforms/main/achievements.js'
import custom from './platforms/main/custom.js'
import items from './platforms/main/items.js'

export default {
coder,
Expand Down
44 changes: 5 additions & 39 deletions src/achievements.js → platforms/android/achievements.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,17 @@
/* TODO: Achievements searchs from O(n) to O(1) through objects */
/* TODO: Option for scenes to require an achievement and if not, fallback to another scene */

import helper from './helper.js'

function init(options) {
const checks = {
'id': {
type: 'string',
extraVerification: (param) => {
if (visualNovel.achievements.find((achievement) => achievement.id == param))
helper.logFatal('An achievement already exists with this id.')
}
},
'name': {
type: 'string',
extraVerification: (param) => {
if (visualNovel.achievements.find((achievement) => achievement.name == param))
helper.logFatal('An achievement already exists with this name.')
}
},
'image': {
type: 'fileInitial',
basePath: `${visualNovel.info.paths.android}/app/src/main/res/raw/`
}
}

helper.verifyParams(checks, options)

visualNovel.achievements = options || []
}
import helper from '../main/helper.js'

function give(page, achievementId) {
if (!visualNovel.achievements.find((achievement) => achievement.id == achievementId))
helper.logFatal(`The achievement '${achievementId}' doesn't exist.`)

if (page.achievements.find((achievement) => achievement.id == achievementId))
helper.logFatal(`The achievement '${achievementId}' was already given.`)

page.achievements.push({
id: achievementId
})

return page
}

function _AchievementGiveFunction() {
function _AchievementGive() {
return helper.codePrepare(`
private fun giveAchievement(${visualNovel.optimizations.hashAchievementIds ? 'achievement: Int' : 'achievement: String, achievementParsed: String'}) {
val inputStream = openFileInput("achievements.json")
Expand All @@ -70,7 +37,7 @@ function _AchievementGiveFunction() {
}

function _SetAchievementsMenu() {
const menu = visualNovel.menu
const menu = AndroidVisualNovel.menu

let achievementsSwitch = helper.codePrepare(`
when (achievements.get${visualNovel.optimizations.hashAchievementIds ? 'Int' : 'String'}(i)) {
Expand Down Expand Up @@ -168,12 +135,11 @@ ${achievementsSwitch}

achievementsCode = helper.finalizeMultipleResources(menu, menu.pages.achievements, achievementsCode)

helper.replace('__PERFORVNM_ACHIEVEMENTS_MENU__', achievementsCode)
helper.replace('Android', '__PERFORVNM_ACHIEVEMENTS_MENU__', achievementsCode)
}

export default {
init,
give,
_AchievementGiveFunction,
_AchievementGive,
_SetAchievementsMenu
}
Loading

0 comments on commit 40290b0

Please sign in to comment.