diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..887c50c --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,32 @@ +name: Gitea Actions Demo +on: + push: + tags: '*' + +defaults: + run: + shell: bash + working-directory: /Users/mac/rp_games/rp_11009 + +jobs: + Explore-Gitea-Actions: + runs-on: mac-local + steps: + - name: update code + run: | + pwd + git pull + echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - name: build + run: | + echo 'build' + code=0 + /Applications/CocosCreator/Creator/3.8.5/CocosCreator.app/Contents/MacOS/CocosCreator --project ./ --build "configPath=./buildConfig_web-mobile.json;" || code=$? + test $code -eq 36 + - name: image compression + run: | + compress-imgs.sh -root ./build/web-mobile/ + - name: upload + run: | + rsync -av --delete build/web-mobile/ zy@dou-dev:/data/rpgames-static/$(basename $PWD) + diff --git a/assets/Main/Scripts/main/comm.ts b/assets/Main/Scripts/main/comm.ts index 50dc2cb..0e45d99 100644 --- a/assets/Main/Scripts/main/comm.ts +++ b/assets/Main/Scripts/main/comm.ts @@ -30,7 +30,7 @@ export function getHistoryUrl() { } export function getLanguage() { - return 'zh'; + // return 'zh'; return language; } diff --git a/build-templates/common/application.ejs b/build-templates/common/application.ejs new file mode 100644 index 0000000..3fdbabd --- /dev/null +++ b/build-templates/common/application.ejs @@ -0,0 +1,142 @@ +<%- include(versionCheckTemplate, { version: '1.0.0'}) %> +let cc; + +function gameStarted() { + return cc?.director?.getScene() +} + +export class Application { + constructor () { + this.settingsPath = '<%= settingsJsonPath %>'; + this.showFPS = <%= showFPS %>; + this.isRB7 = (new URLSearchParams(window.location.search).get('brand') || '').toLowerCase() === 'rb7'; + } + + init (engine) { + cc = engine; + cc.game.onPostBaseInitDelegate.add(this.onPostInitBase.bind(this)); + cc.game.onPostSubsystemInitDelegate.add(this.onPostSystemInit.bind(this)); + + let hasGameStarted = false; + let hasAnimationFinished = false; + const self = this; + + const loadLottie = () =>{ + return new Promise((resolve, reject) => { + const lottie = document.createElement('script'); + lottie.src = 'https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.9.6/lottie.min.js'; + lottie.onload = () => resolve(); + lottie.onerror = () => reject(new Error('Failed to load lottie')); + document.head.appendChild(lottie); + }); + } + + const hideLogoScreen = () => { + if (hasGameStarted && hasAnimationFinished) { + document.getElementById('VideoWrapper').style.display = 'none'; + document.getElementById('RB7Wrapper').style.display = 'none'; + } + } + + const initSplashScreen = () => { + const videoWrapper = document.getElementById('VideoWrapper'); + const rb7Wrapper = document.getElementById('RB7Wrapper'); + + if (self.isRB7) { + videoWrapper.style.display = 'none'; + rb7Wrapper.style.display = 'block'; + loadLottie().then(() => { + initRB7Animation(); + }); + } else { + videoWrapper.style.display = 'block'; + } + } + + const initRB7Animation = () => { + // 设置容器样式 + const rb7Wrapper = document.getElementById('RB7Wrapper'); + const rb7Animation = document.getElementById('rb7Animation'); + + // 设置包裹容器样式 + rb7Wrapper.style.position = 'fixed'; + rb7Wrapper.style.width = '100%'; + rb7Wrapper.style.height = '100%'; + rb7Wrapper.style.top = '0'; + rb7Wrapper.style.left = '0'; + rb7Wrapper.style.background = 'black'; + + // 设置动画容器样式 + rb7Animation.style.position = 'absolute'; + rb7Animation.style.top = '50%'; + rb7Animation.style.left = '50%'; + + if (window.innerWidth > window.innerHeight) { + rb7Animation.style.transform = 'translate(-50%, -50%) scale(0.7)'; + } else { + rb7Animation.style.width = '100%'; + rb7Animation.style.height = '100%'; + rb7Animation.style.transform = 'translate(-50%, -50%) scale(1)'; + } + + + const animation = lottie.loadAnimation({ + container: rb7Animation, + renderer: 'svg', + loop: false, + autoplay: true, + path: '/shared/rb7/introl_RB7.json', + rendererSettings: { + preserveAspectRatio: 'xMidYMid meet' // 保持宽高比并居中 + } + }); + + animation.addEventListener('complete', () => { + hasAnimationFinished = true; + hideLogoScreen(); + }); + } + + const delayTime = self.isRB7 ? 5400 : 2000; + if(!self.isRB7){ + setTimeout(() => { + hasAnimationFinished = true; + hideLogoScreen(); + }, delayTime); + } + + // Init + initSplashScreen(); + + cc.game.onStart = function () { + console.log('on game start!'); + hasGameStarted = true; + hideLogoScreen(); + }; + + } + + onPostInitBase () { + // cc.settings.overrideSettings('assets', 'server', ''); + // do custom logic + } + + onPostSystemInit () { + // do custom logic + } + + start () { + return cc.game.init({ + debugMode: <%= debugMode %> ? cc.DebugMode.INFO : cc.DebugMode.ERROR, + settingsPath: this.settingsPath, + overrideSettings: { + // assets: { + // preloadBundles: [{ bundle: 'main', version: 'xxx' }], + // } + profiling: { + showFPS: this.showFPS, + } + } + }).then(() => cc.game.run()); + } +} diff --git a/build-templates/templates-version.json b/build-templates/templates-version.json new file mode 100644 index 0000000..1d62495 --- /dev/null +++ b/build-templates/templates-version.json @@ -0,0 +1,3 @@ +{ + "web-mobile": "1.0.0" +} diff --git a/build-templates/web-mobile/index.ejs b/build-templates/web-mobile/index.ejs new file mode 100644 index 0000000..10d7d08 --- /dev/null +++ b/build-templates/web-mobile/index.ejs @@ -0,0 +1,123 @@ + + + +
+ + +