Keyboard shortcuts: [ ] step through your POPs, - = zoom, ? lists every key
[ and ] select the previous or next of your POPs, in the order Find a city lists them, and move the map there. - and = (also _ and +) zoom around the middle of the map. ? opens a list of every shortcut, and Help links to it on a computer. Keys are ignored while typing, with Ctrl or Cmd held, or behind an open window.
This commit is contained in:
parent
366c9a2542
commit
23eeddf44f
12 changed files with 165 additions and 1 deletions
|
|
@ -48,5 +48,8 @@ const ACT={
|
|||
findOpen:()=>findOpen(),
|
||||
findGo:({city})=>{if(!isCity(city))return;closeModal();$('dash').hidden=true;ACT.focusCity({city});},
|
||||
focusCity:({city})=>{selectCity(city);const C=CITY[city];cam.x=C.x;cam.y=C.y;cam.z=Math.max(cam.z,1.2);if(innerWidth<760)UI.leftOpen=false;renderLeft();},
|
||||
popStep:({d})=>{const L=popOrder(),n=L.length;if(!n)return;const i=UI.sel&&UI.sel.type==='city'?L.indexOf(UI.sel.id):-1;$('dash').hidden=true;ACT.focusCity({city:L[i<0?(d>0?0:n-1):(i+(d>0?1:n-1))%n]});},
|
||||
zoomStep:({d})=>zoomAt(CW/2,CH/2,d>0?1.25:0.8),
|
||||
keys:()=>showKeys(),
|
||||
selLink:({id})=>{selectLink(id);focusLink(id);},
|
||||
};
|
||||
|
|
|
|||
15
src/game/93-ui/82-keys.js
Normal file
15
src/game/93-ui/82-keys.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* ---------- Keyboard shortcuts: [ ] step through your POPs, - = zoom, ? lists every key ----------
|
||||
Space, 0–4 and Escape live with the map's input (96-map/90-input.js), / with Find a city. */
|
||||
// Your POPs in the order Find a city lists them, so [ and ] walk the same list.
|
||||
const popOrder=()=>S&&S.pops?Object.keys(S.pops).filter(isCity).sort((a,b)=>CITY[a].name.localeCompare(CITY[b].name)):[];
|
||||
function showKeys(){const k=s=>`<span class="kbd">${s}</span>`;
|
||||
const rows=[[k(tr('keys.space')),tr('keys.pause_or_play')],[k('0')+' – '+k('4'),tr('keys.game_speed')],[k('/'),tr('find.find_a_city')],[k('[')+' '+k(']'),tr('keys.previous_or_next_of_your')],[k('-')+' '+k('='),tr('keys.zoom_the_map_out_or')],[k(tr('keys.esc')),tr('keys.close_a_window_or_deselect')],[k('?'),tr('keys.show_this_list')]];
|
||||
openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:28px">⌨️ ${tr('keys.keyboard_shortcuts')}</h2><button class="x" data-act="helpClose" aria-label="${tr('common.close')}">×</button></div>
|
||||
<dl class="keylist">${rows.map(([a,b])=>`<dt>${a}</dt><dd>${b}</dd>`).join('')}</dl><div class="btns" style="margin-top:14px">${btn(UI.started?tr('common.back_to_the_map'):tr('common.got_it'),'helpClose',{},'big')}</div>`,'keys');}
|
||||
document.addEventListener('keydown',e=>{
|
||||
// Many layouts type [ and ] with Option or AltGr held, so Alt alone is fine; Ctrl or Cmd belongs to the browser.
|
||||
if(e.metaKey||(e.ctrlKey&&!e.altKey)||(e.target.closest&&e.target.closest('input,textarea,select,[contenteditable]')))return;
|
||||
const k=e.key,step={'[':-1,']':1}[k],zoom={'-':-1,'_':-1,'=':1,'+':1}[k];
|
||||
if(k==='?'){if(e.repeat)return;if($('modal').hidden){if(S&&UI.started){e.preventDefault();ACT.keys();}}else if($('modal').className==='keys'){e.preventDefault();closeModal();}return;}
|
||||
if(!(step||zoom)||!S||!UI.started||!$('modal').hidden)return;
|
||||
e.preventDefault();if(step)ACT.popStep({d:step});else ACT.zoomStep({d:zoom});});
|
||||
|
|
@ -18,7 +18,7 @@ function showHelp(){
|
|||
<dt>${tr('common.waves')}</dt><dd>${tr('help.your_fiber_links_are_leased_waves')}</dd><dt>${tr('common.95th_percentile')}</dt><dd>${tr('help.transit_bills_sample_your_usage')}</dd><dt>${tr('common.routers')}</dt><dd>${tr('help.each_pop_s_router_model_caps')}</dd><dt>${tr('common.dark_fiber')}</dt><dd>${tr('help.lease_an_iru_or_build_your')}</dd><dt>${tr('common.subsea_cables')}</dt><dd>${tr('help.subsea_waves_can_only_follow_cable')}</dd><dt>${tr('common.latency')}</dt><dd>${tr('help.every_link_has_latency_high')}</dd><dt>${tr('common.noc_dashboard')}</dt><dd>${tr('help.the_chart_button_at_the_top')}</dd><dt>${tr('common.asia')}</dt><dd>${tr('help.a_weird_underserved_market_transit')}</dd><dt>${tr('common.russia')}</dt><dd>${tr('help.moscow_needs_a_mandatory_government')}</dd><dt>${tr('help.events_chains_and_wholesale')}</dt><dd>${tr('help.event_networks_a_final_a_festival')}</dd><dt>${tr('common.bank')}</dt><dd>${tr('help.tap_your_cash_to_open_the')}</dd><dt>${tr('common.lags')}</dt><dd>${tr('help.out_of_port_speed_bundle_up')}</dd><dt>${tr('common.traffic_engineering')}</dt><dd>${tr('help.tap_a_link_to_see_which')}</dd><dt>${tr('common.china')}</dt><dd>${tr('help.mainland_china_needs_a_license_and')}</dd><dt>${tr('common.weird_requirements')}</dt><dd>${tr('help.some_customers_come_with_conditions')}</dd><dt>${tr('common.customer_levels')}</dt><dd>${tr('help.as_your_peak_traffic_and_footprint')}</dd><dt>${tr('help.l2vpn_ddos_protection')}</dt><dd>${tr('help.businesses_may_want_a_private')}</dd><dt>${tr('common.ddos_attack')}</dt><dd>${tr('help.ddos_a_flood_comes_from')}</dd><dt>${tr('common.scrubbing_centers')}</dt><dd>${tr('help.scrubbing_a_center_pulls_floods')}</dd><dt>${tr('common.nni_fabrics')}</dt><dd>${tr('help.megapork_pocketfabric_and')}</dd>
|
||||
<dt>${tr('common.conferences')}</dt><dd>${tr('help.nanog_ripe_denog_and_friends_come')}</dd><dt>${tr('common.modes')}</dt><dd>${tr('help.one_game_four_doors_and_the')}</dd><dt>${tr('common.traceroute')}</dt><dd>${tr('help.tap_traceroute_on_any_of_your')}</dd><dt>${tr('common.badges')}</dt><dd>${tr('help.below_your_goals_sits_a_wall')}</dd><dt>${tr('common.the_giants')}</dt><dd>${tr('help.at_customer_level_3_and_4')}</dd><dt>RouteScript</dt><dd>${tr('help.once_auto_te_is_installed_you')}</dd><dt>Auto-TE</dt><dd>${tr('help.traffic_follows_the_shortest_path_by')}</dd><dt>${tr('common.metro_diversity')}</dt><dd>${tr('help.a_pop_is_one_building_until')}</dd><dt>${tr('common.wave_markets')}</dt><dd>${tr('help.what_a_wave_costs_depends_on')}</dd><dt>${tr('common.regional_quirks')}</dt><dd>${tr('help.in_the_gulf_saudi_pops_need')}</dd><dt>${tr('common.boot_times')}</dt><dd>${tr('help.some_routers_take_forever_to_boot')}</dd><dt>${tr('common.failures')}</dt><dd>${tr('help.things_break_all_the_time_fiber')}</dd>
|
||||
<dt>RouteScript</dt><dd>${tr('help.rules_for_your_auto_te_controller')}</dd>
|
||||
</dl><h3 style="margin:16px 0 0">${tr('help.want_to_know_how_it_really')}</h3>${plugHtml(true)}${chatHtml()}${issueHtml()}</dl><div class="btns" style="margin-top:14px">${btn(UI.started?tr('common.back_to_the_map'):tr('common.got_it'),'helpClose',{},'big')}${RELEASE_NOTES.length?btn(tr('common.what_s_new_in_v',{v:esc(APP_VERSION)}),'whatsNewShow',{},'ghost'):''}${UI.started&&S&&!S.lost?btn(tr('common.start_a_new_network'),'resetAsk',{},'ghost sm'):''}</div><div class="btns" style="margin-top:6px">${UI.started&&S&&!S.lost?btn(tr('common.export_save'),'exportSave',{},'ghost sm'):''}${btn(tr('common.import_a_save'),'importPick',{},'ghost sm')}${btn(tr('common.settings'),'settings',{},'ghost sm')}</div>`);
|
||||
</dl><h3 style="margin:16px 0 0">${tr('help.want_to_know_how_it_really')}</h3>${plugHtml(true)}${chatHtml()}${issueHtml()}</dl><div class="btns" style="margin-top:14px">${btn(UI.started?tr('common.back_to_the_map'):tr('common.got_it'),'helpClose',{},'big')}${RELEASE_NOTES.length?btn(tr('common.what_s_new_in_v',{v:esc(APP_VERSION)}),'whatsNewShow',{},'ghost'):''}${UI.started&&S&&!S.lost?btn(tr('common.start_a_new_network'),'resetAsk',{},'ghost sm'):''}</div><div class="btns" style="margin-top:6px">${UI.started&&S&&!S.lost?btn(tr('common.export_save'),'exportSave',{},'ghost sm'):''}${btn(tr('common.import_a_save'),'importPick',{},'ghost sm')}${btn(tr('common.settings'),'settings',{},'ghost sm')}${isPhone()?'':btn(tr('keys.keyboard_shortcuts'),'keys',{},'ghost sm')}</div>`);
|
||||
}
|
||||
function showWin(){setTimeout(()=>{const m=$('modalCard');if(m&&!m.querySelector('[data-act=share]'))m.insertAdjacentHTML('beforeend',`<div class="btns" style="margin-top:8px">${btn(tr('help.share_my_network'),'share',{},'pink')}</div><p class="meta" style="margin:12px 0 0">${tr('help.you_built_a_cartoon_internet_now')}</p>${plugHtml(true)}`);},0);openModal(`<h1 style="font-family:var(--display);font-size:44px;margin:0">${tr('help.you_re_a_tier_1')}</h1><p class="tagline">${tr('help.name_as_asn_is_transit_free',{name:esc(S.name),asn:S.asn,days:S.day,n:S.stats.incidents})}</p>${btn(tr('common.keep_building'),'keepPlaying',{},'pink big')}`);sfx('coin');}
|
||||
function showLose(){openModal(`<h1 style="font-family:var(--display);font-size:40px;margin:0">${tr('common.bankrupt')}</h1><p class="tagline">${tr('help.the_bank_repossessed_your_routers',{name:esc(S.name),days:S.day,peak:fmtG(S.stats.peak)})}</p>${btn(tr('common.try_again'),'newgame',{},'pink big')}`);if(UI.slot){const id=UI.slot;slotDrop(id);slotFree(id);}}
|
||||
|
|
|
|||
|
|
@ -2369,6 +2369,15 @@
|
|||
"interface.tubecoin_moved_down_p_on_the":"TubeCoin moved down {p}% on the way to your account.",
|
||||
"interface.tubecoin_moved_up_p_on_the":"TubeCoin moved up {p}% on the way to your account.",
|
||||
"interface.you_bought_out_bank_they_flew":"<b>You bought out {bank}.</b><br>They flew off to find another startup.",
|
||||
"keys.close_a_window_or_deselect":"Close a window, or deselect a city or link",
|
||||
"keys.esc":"Esc",
|
||||
"keys.game_speed":"Game speed: ½×, 1×, 2×, 4×, 8×",
|
||||
"keys.keyboard_shortcuts":"Keyboard shortcuts",
|
||||
"keys.pause_or_play":"Pause or play",
|
||||
"keys.previous_or_next_of_your":"Previous or next of your POPs",
|
||||
"keys.show_this_list":"Show this list",
|
||||
"keys.space":"Space",
|
||||
"keys.zoom_the_map_out_or":"Zoom the map out or in",
|
||||
"lease_swaps.cap_fabric_circuit":"{cap} fabric circuit",
|
||||
"lease_swaps.cap_on_a_dark_fiber_iru":"{cap} on a dark fiber IRU",
|
||||
"lease_swaps.cap_wave":"{cap} wave",
|
||||
|
|
|
|||
|
|
@ -160,6 +160,9 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
|
|||
.gl dt{font-family:var(--display);font-weight:800;font-size:16px;margin-top:10px}
|
||||
.gl dd{margin:2px 0 0;color:var(--ink2);line-height:1.45;font-size:13px}
|
||||
.kbd{display:inline-block;border:2px solid var(--ink);border-radius:6px;padding:0 5px;font-weight:900;font-size:11px;background:var(--soft)}
|
||||
.keylist{display:grid;grid-template-columns:auto 1fr;gap:10px 16px;align-items:center;margin:14px 0 0}
|
||||
.keylist dt{margin:0;white-space:nowrap}.keylist dd{margin:0;color:var(--ink2);font-size:14px}
|
||||
.keylist .kbd{font-size:13px;padding:1px 7px;min-width:12px;text-align:center}
|
||||
|
||||
/* "Your networks" on the title screen: one big tap target per network, a small ⋯ for export and delete. */
|
||||
.slots{display:flex;flex-direction:column;gap:7px;margin-bottom:6px;max-height:min(46vh,330px);overflow:auto;padding:2px 2px 5px}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue