L0op8ack Posted October 7, 2012 Share Posted October 7, 2012 (edited) Life will be much easier while creating big mission with "Group Clone" export part of BLINDSPOTs_ModdedME for FC2/BS1 to DCS World diff -u orig//me_mission.lua new//me_mission.lua --- orig//me_mission.lua 2012-10-07 08:01:47.000000000 +0800 +++ new//me_mission.lua 2012-10-07 08:10:29.000000000 +0800 @@ -3103,6 +3103,67 @@ return group end +--NFI_591/bird-23 BEGIN +function duplicate_group(group) + local groupNew = create_group(group.boss.name, group.type, check_group_name(group.name), group.start_time, group.x+0.00010, group.y+0.00010) + + groupNew.hidden = group.hidden + groupNew.task = group.task + groupNew.taskSelected = group.taskSelected + groupNew.start_time = group.start_time + groupNew.task = group.task + groupNew.visible = group.visible + groupNew.x = group.x+0.00010 + groupNew.y = group.y+0.00010 + + + for a=1, #group.units do + local u = group.units[a] + local uNew = insert_unit(groupNew, u.type, u.skill, a, check_unit_name(u.name), u.x+0.00010, u.y+0.00010, u.heading) + uNew.livery_id = u.livery_id + + if u.payload then + uNew.payload = {} + U.copyTable(uNew.payload, u.payload) + end + end; + + if group.route then + if group.route.points then + for a=1, #group.route.points do + local wp = group.route.points[a] + local wpNew = insert_waypoint(groupNew, a, wp.type, wp.x, wp.y, wp.alt, wp.speed, wp.name) + wpNew.action = wp.action + if wp.airdromeId then + wpNew.airdromeId = wp.airdromeId + end + if wp.targets then + for b=1, #wp.targets do + local tgt = wp.targets[b] + local tgtNew = insert_target(wpNew, b, tgt.x, tgt.y, tgt.radius, tgt.name) + + if tgt.categories then + tgtNew.categories = {} + U.copyTable(tgtNew.categories, tgt.categories) + end + end + end + end + end + end + + if groupNew.route and groupNew.route.points and #groupNew.route.points > 0 then + local wpt = groupNew.route.points[1] + MapWindow.move_waypoint(wpt.boss, wpt.index, wpt.x+0.00010, wpt.y+0.00010) + end + + + create_group_objects(groupNew) + update_group_map_objects(groupNew) + return groupNew; +end; +--NFI_591/bird-23 END + ------------------------------------------------------------------------------- -- function create_navpoint(vd, mapX, mapY) @@ -3720,7 +3781,7 @@ if not group.x then group.x = group.route.points[1].x group.y = group.route.points[1].y - end + end if group.type == 'static' then x = group.x diff -u orig//me_units_list_form.lua new//me_units_list_form.lua --- orig//me_units_list_form.lua 2012-10-07 08:02:05.000000000 +0800 +++ new//me_units_list_form.lua 2012-10-07 08:10:30.000000000 +0800 @@ -8,6 +8,9 @@ local Theme = base.require('Theme') local U = base.require('me_utilities') local i18n = base.require('i18n') +-- NFI_591/bird-23 BEGIN +local Button = base.require('Button') +-- NFI_591/bird-23 END i18n.setup(_M) @@ -55,7 +58,15 @@ countryFilter:setBounds(xPos, yPos, W, H) countryFilter:setReadonly(true); window:insertWidget(countryFilter); - +-- NFI_591/bird-23 BEGIN + xPos = xPos + W + 3 + W = 70 + duplicateBtn = Button.new("CLONE") + duplicateBtn:setBounds(xPos, yPos, W, H) + window:insertWidget(duplicateBtn) + duplicateBtn:setEnabled(false) +-- NFI_591/bird-23 END + --[[ local theme = window:getTheme(); theme.titleHeight = 10; window:setTheme(theme);--]] diff -u orig//me_units_list.lua new//me_units_list.lua --- orig//me_units_list.lua 2012-10-07 08:02:05.000000000 +0800 +++ new//me_units_list.lua 2012-10-07 08:12:21.000000000 +0800 @@ -6,6 +6,10 @@ local GridHeaderCell = base.require('GridHeaderCell') local U = base.require('me_utilities') local MapWindow = base.require('me_map_window') +-- NFI_591/bird-23 BEGIN +local MsgWindow = base.require('MsgWindow') +-- NFI_591/bird-23 END + local Theme = base.require('Theme') local form = base.require('me_units_list_form') local MissionModule = base.require('me_mission') @@ -137,6 +141,9 @@ window = form.create(x, y, w, h, update) grid = form.grid filters = form.filters +-- NFI_591/bird-23 BEGIN + form.duplicateBtn.onChange = onClickDuplicate; +-- NFI_591/bird-23 END updateCountriesCombo() form.countryFilter:setText(cdata.allCountries) form.countryFilter.onChange = onCountryChange @@ -145,6 +152,19 @@ createGrid() end +-- NFI_591/bird-23 BEGIN +function onClickDuplicate() + if currentGroup then + local g = MissionModule.duplicate_group(currentGroup) + MissionModule.remove_group_map_objects(g) + MissionModule.create_group_map_objects(g) + selectGroup(g) + selectRow(g, nil) + end; + update() +end; +-- NFI_591/bird-23 END + function onCountryChange(self, item) update() end @@ -284,8 +304,13 @@ -- 恹溴?屐 沭箫矬 磬 赅痱? function selectGroup(group) if (not group) or (not group.boss) or (not group.boss.boss) or (not applyFilter(group)) then + form.duplicateBtn:setEnabled(false) + currentGroup = nil return end + form.duplicateBtn:setEnabled(true) + currentGroup = group + if group.hidden then MapWindow.unselectAll() MapWindow.selectedGroup = group Edited October 7, 2012 by L0op8ack Link to comment Share on other sites More sharing options...
Jona33 Posted October 7, 2012 Share Posted October 7, 2012 There's already a copy and paste function in the ME. Always remember. I don't have a clue what I'm doing Link to comment Share on other sites More sharing options...
Recommended Posts