Skip to content

Commit

Permalink
Merge pull request #591 from cj123/show-dlc-mod
Browse files Browse the repository at this point in the history
Show dlc mod
  • Loading branch information
cj123 authored Oct 25, 2019
2 parents c3e3dbe + e62ad98 commit e887c4c
Show file tree
Hide file tree
Showing 8 changed files with 285 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ v1.5.2

Added:

* Added information about whether a car/track is part of a DLC or a Mod when creating an event.
* Discord Enhancements (Thanks @cheesegrits!):
- Splits the '!schedule' command into '!sessions' (full "wall of text" individual session calendar, restricted to one week ahead) and '!schedule' (abbreviated, one per race calendar). This still needs work, as can easily exceed Discord's max msg length.

Expand Down
15 changes: 15 additions & 0 deletions cmd/server-manager/typescript/sass/_custom-race.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
margin-bottom: 5px;
}

.ms-container .ms-selectable li.ms-hover, .ms-container .ms-selection li.ms-hover {
cursor: pointer;
color: #fff;
text-decoration: none;
background-color: #08c!important;
}

.bg-dlc {
background-color: #e2d9f3
}

.bg-mod {
background-color: #f2dede
}


.race-setup .pit-boxes {
padding-top: calc(0.375rem + 1px);
Expand Down
6 changes: 2 additions & 4 deletions cmd/server-manager/typescript/src/CarSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import KeyPressEvent = JQuery.KeyPressEvent;
interface SearchResult {
CarName: string;
CarID: string;
Class: string;
// Tags: string[];
}

Expand Down Expand Up @@ -50,10 +51,7 @@ export class CarSearch {
}

for (const car of data) {
$carsSelect.multiSelect("addOption", {
value: car.CarID,
text: car.CarName,
});
$carsSelect.append('<option value=' + car.CarID + " class=" + car.Class + ">" + car.CarName + "</option>")
}

$carsSelect.multiSelect('refresh');
Expand Down
8 changes: 7 additions & 1 deletion cmd/server-manager/views/pages/custom-race/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,17 @@ <h1 class="text-center">
<div class="col-sm-9">
<select class="form-control" name="Track" id="Track">
{{ range $index, $track := .TrackOpts }}
<option value="{{ $track.Name }}" {{ if eq $track.Name $f.Track }}selected="selected" {{ end }}>
<option value="{{ $track.Name }}" {{ if eq $track.Name $f.Track }}selected="selected" {{ end }}
class="{{ if $track.IsPaidDLC }}bg-dlc{{ end }}{{ if $track.IsMod }}bg-mod{{ end }}">
{{ prettify $track.Name false }}
</option>
{{ end }}
</select>

<small style="cursor: default;">
<span class="badge bg-dlc">DLC</span>
<span class="badge bg-mod">Mod</span>
</small>
</div>
</div>

Expand Down
9 changes: 8 additions & 1 deletion cmd/server-manager/views/pages/quick-race.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ <h1 class="text-center">Quick Race</h1>
<div class="col-sm-9">
<select class="form-control" name="Track" id="Track">
{{ range $index, $track := .TrackOpts }}
<option value="{{ $track.Name }}">{{ prettify $track.Name false }}</option>
<option value="{{ $track.Name }}" class="{{ if $track.IsPaidDLC }}bg-dlc{{ end }}{{ if $track.IsMod }}bg-mod{{ end }}"
>{{ prettify $track.Name false }}</option>
{{ end }}
</select>

<small style="cursor: default;">
<span class="badge bg-dlc">DLC</span>
<span class="badge bg-mod">Mod</span>
</small>
</div>
</div>

Expand Down Expand Up @@ -58,6 +64,7 @@ <h1 class="text-center">Quick Race</h1>
{{ template "cars" dict "CarOpts" $.CarOpts "Current" nil }}

<small>

Models of cars allowed in the server. Any cars you choose will be evenly distributed across the
number of available pitboxes for the track when the Entry List is created.

Expand Down
9 changes: 7 additions & 2 deletions cmd/server-manager/views/partials/race-builder/cars.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@
{{ end }}
{{ end }}

<option value="{{ $car.Name }}" {{ if $selected }} selected="selected" {{ end }}>{{ prettify $car.Name true }}</option>
<option class="{{ if $car.IsPaidDLC }}bg-dlc{{ end }}{{ if $car.IsMod }}bg-mod{{ end }}" value="{{ $car.Name }}" {{ if $selected }} selected="selected" {{ end }}>{{ prettify $car.Name true }}</option>
{{ end }}
</select>

<div class="text-black-50 mb-2">
<small class="d-inline" style="cursor: default;">
<span class="badge bg-dlc">DLC</span>
<span class="badge bg-mod">Mod</span>
</small>

<div class="text-black-50 mb-2 d-inline">
<div class="float-right">
<small><a href="#" data-toggle="collapse" data-target="#searchHelp" aria-expanded="false" aria-controls="searchHelp">Search Help</a></small>
</div>
Expand Down
207 changes: 207 additions & 0 deletions content_cars.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ func (c Car) PrettyName() string {
return prettifyName(c.Name, true)
}

func (c Car) IsPaidDLC() bool {
if _, ok := isCarPaidDLC[c.Name]; ok {
return isCarPaidDLC[c.Name]
} else {
return false
}
}

func (c Car) IsMod() bool {
_, ok := isCarPaidDLC[c.Name]

return !ok
}

type Cars []*Car

func (cs Cars) AsMap() map[string][]string {
Expand Down Expand Up @@ -676,6 +690,7 @@ func (ch *CarsHandler) list(w http.ResponseWriter, r *http.Request) {
type carSearchResult struct {
CarName string `json:"CarName"`
CarID string `json:"CarID"`
Class string `json:"Class"`
// Tags []string `json:"Tags"`
}

Expand All @@ -693,9 +708,20 @@ func (ch *CarsHandler) searchJSON(w http.ResponseWriter, r *http.Request) {
var searchResults []carSearchResult

for _, car := range cars {
var class string

if car.IsPaidDLC() {
class = "bg-dlc"
}

if car.IsMod() {
class = "bg-mod"
}

searchResults = append(searchResults, carSearchResult{
CarName: car.Details.Name,
CarID: car.Name,
Class: class,
// Tags: car.Details.Tags,
})
}
Expand Down Expand Up @@ -845,3 +871,184 @@ func (ch *CarsHandler) rebuildSearchIndex(w http.ResponseWriter, r *http.Request
AddFlash(w, r, "Started re-indexing cars!")
http.Redirect(w, r, r.Referer(), http.StatusFound)
}

var isCarPaidDLC = map[string]bool{
"abarth500": false,
"abarth500_s1": false,
"alfa_romeo_giulietta_qv": false,
"alfa_romeo_giulietta_qv_le": false,
"bmw_1m": false,
"bmw_1m_s3": false,
"bmw_m3_e30": false,
"bmw_m3_e30_drift": false,
"bmw_m3_e30_dtm": false,
"bmw_m3_e30_gra": false,
"bmw_m3_e30_s1": false,
"bmw_m3_e92": false,
"bmw_m3_e92_drift": false,
"bmw_m3_e92_s1": false,
"bmw_m3_gt2": false,
"bmw_z4": false,
"bmw_z4_drift": false,
"bmw_z4_gt3": false,
"bmw_z4_s1": false,
"ferrari_312t": false,
"ferrari_458": false,
"ferrari_458_gt2": false,
"ferrari_458_s3": false,
"ferrari_599xxevo": false,
"ferrari_f40": false,
"ferrari_f40_s3": false,
"ferrari_laferrari": false,
"ks_abarth500_assetto_corse": false,
"ks_abarth_595ss": false,
"ks_abarth_595ss_s1": false,
"ks_abarth_595ss_s2": false,
"ks_alfa_33_stradale": false,
"ks_alfa_giulia_qv": false,
"ks_alfa_mito_qv": false,
"ks_alfa_romeo_155_v6": false,
"ks_alfa_romeo_4c": false,
"ks_alfa_romeo_gta": false,
"ks_audi_a1s1": true,
"ks_audi_r18_etron_quattro": true,
"ks_audi_r8_lms": false,
"ks_audi_r8_lms_2016": true,
"ks_audi_r8_plus": true,
"ks_audi_sport_quattro": false,
"ks_audi_sport_quattro_rally": false,
"ks_audi_sport_quattro_s1": false,
"ks_audi_tt_cup": true,
"ks_audi_tt_vln": true,
"ks_bmw_m235i_racing": false,
"ks_bmw_m4": true,
"ks_bmw_m4_akrapovic": false,
"ks_corvette_c7_stingray": true,
"ks_corvette_c7r": false,
"ks_ferrari_250_gto": true,
"ks_ferrari_288_gto": true,
"ks_ferrari_312_67": true,
"ks_ferrari_330_p4": true,
"ks_ferrari_488_gt3": true,
"ks_ferrari_488_gtb": true,
"ks_ferrari_812_superfast": true,
"ks_ferrari_f138": true,
"ks_ferrari_f2004": true,
"ks_ferrari_fxx_k": false,
"ks_ferrari_sf15t": true,
"ks_ferrari_sf70h": true,
"ks_ford_escort_mk1": false,
"ks_ford_gt40": false,
"ks_ford_mustang_2015": true,
"ks_glickenhaus_scg003": false,
"ks_lamborghini_aventador_sv": true,
"ks_lamborghini_countach": false,
"ks_lamborghini_countach_s1": false,
"ks_lamborghini_gallardo_sl": true,
"ks_lamborghini_gallardo_sl_s3": false,
"ks_lamborghini_huracan_gt3": false,
"ks_lamborghini_huracan_performante": false,
"ks_lamborghini_huracan_st": false,
"ks_lamborghini_miura_sv": false,
"ks_lamborghini_sesto_elemento": false,
"ks_lotus_25": false,
"ks_lotus_3_eleven": true,
"ks_lotus_72d": false,
"ks_maserati_250f_12cyl": true,
"ks_maserati_250f_6cyl": true,
"ks_maserati_alfieri": false,
"ks_maserati_gt_mc_gt4": true,
"ks_maserati_levante": false,
"ks_maserati_mc12_gt1": true,
"ks_maserati_quattroporte": false,
"ks_mazda_787b": false,
"ks_mazda_miata": false,
"ks_mazda_mx5_cup": true,
"ks_mazda_mx5_nd": true,
"ks_mazda_rx7_spirit_r": true,
"ks_mazda_rx7_tuned": true,
"ks_mclaren_570s": true,
"ks_mclaren_650_gt3": false,
"ks_mclaren_f1_gtr": false,
"ks_mclaren_p1": false,
"ks_mclaren_p1_gtr": true,
"ks_mercedes_190_evo2": false,
"ks_mercedes_amg_gt3": false,
"ks_mercedes_c9": false,
"ks_nissan_370z": true,
"ks_nissan_gtr": true,
"ks_nissan_gtr_gt3": false,
"ks_nissan_skyline_r34": true,
"ks_pagani_huayra_bc": false,
"ks_porsche_718_boxster_s": true,
"ks_porsche_718_boxster_s_pdk": true,
"ks_porsche_718_cayman_s": true,
"ks_porsche_718_spyder_rs": true,
"ks_porsche_908_lh": true,
"ks_porsche_911_carrera_rsr": true,
"ks_porsche_911_gt1": true,
"ks_porsche_911_gt3_cup_2017": true,
"ks_porsche_911_gt3_r_2016": true,
"ks_porsche_911_gt3_rs": true,
"ks_porsche_911_r": true,
"ks_porsche_911_rsr_2017": true,
"ks_porsche_917_30": true,
"ks_porsche_917_k": true,
"ks_porsche_918_spyder": true,
"ks_porsche_919_hybrid_2015": true,
"ks_porsche_919_hybrid_2016": true,
"ks_porsche_935_78_moby_dick": true,
"ks_porsche_962c_longtail": true,
"ks_porsche_962c_shorttail": true,
"ks_porsche_991_carrera_s": true,
"ks_porsche_991_turbo_s": true,
"ks_porsche_cayenne": false,
"ks_porsche_cayman_gt4_clubsport": true,
"ks_porsche_cayman_gt4_std": true,
"ks_porsche_macan": false,
"ks_porsche_panamera": false,
"ks_praga_r1": false,
"ks_ruf_rt12r": false,
"ks_ruf_rt12r_awd": false,
"ks_toyota_ae86": true,
"ks_toyota_ae86_drift": true,
"ks_toyota_ae86_tuned": true,
"ks_toyota_celica_st185": true,
"ks_toyota_gt86": true,
"ks_toyota_supra_mkiv": true,
"ks_toyota_supra_mkiv_drift": true,
"ks_toyota_supra_mkiv_tuned": true,
"ks_toyota_ts040": true,
"ktm_xbow_r": false,
"lotus_2_eleven": false,
"lotus_2_eleven_gt4": false,
"lotus_49": false,
"lotus_98t": false,
"lotus_elise_sc": false,
"lotus_elise_sc_s1": false,
"lotus_elise_sc_s2": false,
"lotus_evora_gtc": false,
"lotus_evora_gte": false,
"lotus_evora_gte_carbon": false,
"lotus_evora_gx": false,
"lotus_evora_s": false,
"lotus_evora_s_s2": false,
"lotus_exige_240": false,
"lotus_exige_240_s3": false,
"lotus_exige_s": false,
"lotus_exige_s_roadster": false,
"lotus_exige_scura": false,
"lotus_exige_v6_cup": false,
"lotus_exos_125": false,
"lotus_exos_125_s1": false,
"mclaren_mp412c": false,
"mclaren_mp412c_gt3": false,
"mercedes_sls": false,
"mercedes_sls_gt3": false,
"p4-5_2011": false,
"pagani_huayra": false,
"pagani_zonda_r": false,
"ruf_yellowbird": false,
"shelby_cobra_427sc": false,
"tatuusfa1": false,
}
38 changes: 38 additions & 0 deletions content_tracks.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ func (t Track) PrettyName() string {
return prettifyName(t.Name, false)
}

func (t Track) IsPaidDLC() bool {
if _, ok := isTrackPaidDLC[t.Name]; ok {
return isTrackPaidDLC[t.Name]
} else {
return false
}
}

func (t Track) IsMod() bool {
_, ok := isTrackPaidDLC[t.Name]

return !ok
}

const defaultLayoutName = "<default>"

func (t *Track) LayoutsCSV() string {
Expand Down Expand Up @@ -611,3 +625,27 @@ func trackSummary(track, layout string) string {
return track
}
}

var isTrackPaidDLC = map[string]bool{
"ks_barcelona": true,
"ks_black_cat_country": false,
"ks_brands_hatch": true,
"ks_drag": false,
"ks_highlands": false,
"ks_laguna_seca": false,
"ks_monza66": false,
"ks_nordschleife": true,
"ks_nurburgring": false,
"ks_red_bull_ring": true,
"ks_silverstone": false,
"ks_silverstone1967": false,
"ks_vallelunga": false,
"ks_zandvoort": false,
"monza": false,
"mugello": false,
"magione": false,
"drift": false,
"imola": false,
"spa": false,
"trento-bondone": false,
}

0 comments on commit e887c4c

Please sign in to comment.